shetlandbob
Programmer
Hello, I know nothing about sockets and how they connect, so this might be a bit basic!!
I'm trying to connect to a socket, so I create a socket as shown below:
I assume I now have to connect to the socket?? yes? No? Is this when I would have to specify the IP address (etc... what other info do I have to give it?) of the server I'm connecting to that I want to get the information from? (if I'm way off track then feel free to laugh out loud, but at least tell me!!) If thats what I'm to do, how do I do it???
Then do I get a message through the socket by using the following code:
If I run the above code then I get the message box about the socket not being connected.
Any help much appreciated, as I'm on a slipery slope with this one!!!
I'm trying to connect to a socket, so I create a socket as shown below:
Code:
WSADATA wsData;
WORD wVer = MAKEWORD(2,2);
SOCKET s;
WSAStartup(wVer,&wsData);
s = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
err = WSAGetLastError();
if (s == INVALID_SOCKET) MessageBox ("INVALID_SOCKET");
I assume I now have to connect to the socket?? yes? No? Is this when I would have to specify the IP address (etc... what other info do I have to give it?) of the server I'm connecting to that I want to get the information from? (if I'm way off track then feel free to laugh out loud, but at least tell me!!) If thats what I'm to do, how do I do it???
Then do I get a message through the socket by using the following code:
Code:
char socketMessage[80];
value = recv ( s, socketMessage, 80, MSG_PEEK );
err = WSAGetLastError();
if ( err == WSAENOTCONN ) MessageBox ("WSAENOTCONN" );
If I run the above code then I get the message box about the socket not being connected.
Any help much appreciated, as I'm on a slipery slope with this one!!!