[newbie][OFF][Win32][Winsock] reading from and writing to connections - Unix

This is a discussion on [newbie][OFF][Win32][Winsock] reading from and writing to connections - Unix ; Dear everyone! I'm new to network programming and I require some help. =) So I decided to write a little utility similar to netcat as 2nd networking program, and when I'm writing to port 25 (an Exim mailer daemon is ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: [newbie][OFF][Win32][Winsock] reading from and writing to connections

  1. [newbie][OFF][Win32][Winsock] reading from and writing to connections

    Dear everyone!
    I'm new to network programming and I require some help. =)
    So I decided to write a little utility similar to netcat as 2nd
    networking program, and when I'm writing to port 25 (an Exim mailer
    daemon is sitting on it), it gives me an SMTP code 554 (Synchronization
    error). I've found out it means I broke the protocol with writing to it
    before receiveing code 220 (the banner). I'd like to fix it, the problem
    is I have no idea how to :\. Since it is a generic application, if I
    used recv(), before sending a command it could be hanging there blocking
    until the end of time if I used it to connect to another service.

    the source: http://pastebin.ca/1014034

    screenshot about the error:
    http://img123.imageshack.us/img123/5176/554lh6.jpg

    packets captured with wireshark: http://filebin.ca/oyudtg/mync.pcap

    Any help is appreciated.

    I know it is offtopic here (as the topic shows) a bit since I am trying
    this in win32 environment, but since my problem is generic enough I
    thought I would try it here. Also if you can direct me to the right
    group, that would be nice too =)

  2. Re: [newbie][OFF][Win32][Winsock] reading from and writing to connections

    Leslie Kis-Adam wrote:
    > I'm new to network programming and I require some help. =)
    > So I decided to write a little utility similar to netcat as 2nd
    > networking program, and when I'm writing to port 25 (an Exim mailer
    > daemon is sitting on it), it gives me an SMTP code 554 (Synchronization
    > error). I've found out it means I broke the protocol with writing to it
    > before receiveing code 220 (the banner). I'd like to fix it, the problem
    > is I have no idea how to :\. Since it is a generic application, if I
    > used recv(), before sending a command it could be hanging there blocking
    > until the end of time if I used it to connect to another service.


    But that's not the way the SMTP protocol works. You're supposed
    to first receive the "220" message from the server before you
    start the send it data. If you're concerned about never getting
    the initial message because the server is for some reason never
    sendind it then under UNIX I would use select() with a timeout
    to wait for something to be readable from the socket, with
    select() bailing out after the timeout. But, unfortunately, I
    have no idea if there's the same function under Win32 (butI am
    rather sure there's at least something similar).

    > the source: http://pastebin.ca/1014034


    Yes, looks like you simply send something and only then listen.
    This might be ok for some protocols but will fail with a lot of
    others. Perhaps your program needs some option (switch in Win32-
    speak?) that tells it of it's supposed to talk first or listen
    first...
    Regards, Jens
    --
    \ Jens Thoms Toerring ___ jt@toerring.de
    \__________________________ http://toerring.de

+ Reply to Thread