I'm trying to write an experimental server program that accepts a connection and sends a message to the client. I got the client to connect, but I can't seem to send the message without doing really odd things.
For example, in this snip, conn
is a connected socket:
int sendRes;
char buf[1024];
strcpy_s(buf,"Testing!");
sendRes = send(conn,buf,strlen(buf),0);
Well, when I connect to it via Telnet, it displays nothing and just quits. However, when I add the line cout << sendRes
to the end of this snip, it suddenly works and displays Testing! on Telnet, just like it should.
And so, I would like to ask anyone who knows, why is it acting like so?