[c# form] Readline sockets, telnet

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • piercy
    New Member
    • Aug 2007
    • 77

    [c# form] Readline sockets, telnet

    Hi, I need to be able to get some data from a telnet session to verify a login. There server I wish tot telnet with is a SMTP server. I already have code in place to send commands to the server and to allow me to connect to it via sockets.

    So far the only thing I have come up with is:
    Code:
    			//s being my open socket...
    			Stream q = new NetworkStream(s); 
    			StreamReader sr = new StreamReader(q);
    			string output = sr.ReadLine();
    However, this freezes when it trys to ReadLine();. Would someone be able to give me a push in the right direction? Ive done some Google searches but they all seem to do it the same or similar ways. And each way I try still freezes. VS2003 output windows has the reply from the server so I know there is a reply there I just can’t get at it.

    All help is much appreciated.

    Thanks,
    Piercy
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    It might be waiting for the sequence of "\r\n" and your server might only be returning "\n".
    I would suggest reading one byte (character) at a time and building your own string from it. That way when a '\n' comes down, you know you have a complete "line"

    (Note: I said one byte at a time but if you're comfortable with byte[] you can do that too and just index through them to find a '\n' if you want)

    Comment

    • piercy
      New Member
      • Aug 2007
      • 77

      #3
      You was right... it was waiting for \n(\r) i was just about to reply back saying i fixed it. does anyone know how i can just get the auth types back? i can do ehlo and its in the list but ifi just want it in a single line?


      I'll keep googleing about this anyway :)

      thanks,
      Piercy

      Comment

      Working...