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



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
.



Relevant Pages

  • Re: send and receive a large byte[] over network?
    ... clueless. ... I would suggest using an OutputStream, and simply writing the array to that stream. ... If you need the ability to resume after disconnect, you might look into using FTP or some similar protocol. ...
    (comp.lang.java.programmer)
  • Re: What protocol to choose for a new fuzzer?
    ... work on a new network protocol fuzzer which I intend ... Python but my intention is to learn it by writing the ... I am looking for a protocol which is ...
    (Pen-Test)
  • Re: UDP-TCP
    ... > i m writing a client-server kind of application... ... > factors that i should affect my choice of the protocol (UDP or TCP). ...
    (comp.programming)
  • Re: DSDV protocol source code
    ... on DSDV r plz tell the steps in writing a protocol.. ...
    (comp.lang.c)