Re: [newbie][OFF][Win32][Winsock] reading from and writing to connections
- From: jt@xxxxxxxxxxx (Jens Thoms Toerring)
- Date: 10 May 2008 21:50:14 GMT
Leslie Kis-Adam <dfighter@xxxxxxxxxxx> 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@xxxxxxxxxxx
\__________________________ http://toerring.de
.
- References:
- [newbie][OFF][Win32][Winsock] reading from and writing to connections
- From: Leslie Kis-Adam
- [newbie][OFF][Win32][Winsock] reading from and writing to connections
- Prev by Date: [newbie][OFF][Win32][Winsock] reading from and writing to connections
- Next by Date: Re: socket behavior - already bound
- Previous by thread: [newbie][OFF][Win32][Winsock] reading from and writing to connections
- Index(es):
Relevant Pages
|