Sending commands to a socket

David Lindon

Golden Master
Messages
15,233
I'm trying to write an SMTP wrapper and I'm connecting to the mail server with winsock and connect successfully but how do I send the commands?

send(lhSocket,"HELO\\r",strlen("HELO\\r"),0);

Does it need to be \n to end the command?
 
it depends on the language that you are using
if you were using VB...
VB uses the syntax Winsock1.SendData("HELO")

You'd need to add carriage return line feeds as well.


but I can see that you are using C, and the code is.
just cause I feel it makes it easier to debug,
Code:
msgString = "HELO\r\n";
msgStringLen=strlen(mgsString); /* Determine input length */
/* Send the string to the server */
if (send(sock,msgString,msgStringLen, 0) !=msgStringLen)DieWithError("send() sent a different number of bytes than expected");
 
Back
Top Bottom