This line:
is wrong.Code:if (hSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)==0) { // create successful ..
is correct. In the first case, you're saying that the socket is only successfuly created if socket() returns 0. Actually, socket() returns INVALID_SOCKET if it fails to create a socket, or a handle to the socket otherwise. So the code I've written says "as long as hSocket is not INVALID_SOCKET" then creating the socket succeeded.Code:if ( (hSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) != INVALID_SOCKET) { // create succesful...
Good luck!
PS -- for more information check the msdn page on the functions you're using. For example, here is the page on socket: http://msdn2.microsoft.com/en-us/library/ms740506.aspx





Reply With Quote