-
Winsock Problem
Hi,
Im having some problems with a basic winsock server, when my servers running and i open a raw telnet connection to it, i can only send single characters rather than full strings which is what i need.
this is my server code for recived data:
Code:
void Get_Message(int clIndex)
{
int nRet;
char data[1024];
nRet = recv(Client[clIndex].ClientSocket, data, sizeof(data), 0);
char *ClientIp = inet_ntoa(Client[clIndex].ClientAddr.sin_addr);
if (nRet == 0) {
Log("Client disconnected: "), Log(ClientIp), Log("\n");
Disconnect(clIndex);
}
else {
Log("<"), Log(ClientIp), Log("> ");
data[nRet] = '\0';
// Start data output
cout << data;
Log("\n");
}
}
As i say my code works fine, but in a telnet connection i can only send one character at a time rather than a string that i need, the server is simply getting it character by character :mad:
Thanks for any help guys
TNT
-
Well.....as of recently we have a board specifically for this type of question.
Since I know next to nothing about winsock, perhaps it would be best answered and moved to the network board.
:cool:
-
Dam, sorry i never noticed that board, :rolleyes: can someone please move this
-
SOCK_RAW sockets are generally not intended for the purpose you are using it for. Use SOCK_STREAM. Also, SOCK_RAW is a poor decision to use in your applications simply because it requires administrative privileges.
-
Hi thanks do u have any tutorials on sock_streams or can you reccomend any good books covering them in detail,
Thanks
TNT
-
Go to google and search for Beej's Guide to Networking or something like that. Its a magnificent book that teaches all about stream and datagram sockets (sorry but I dont have the link on me).