Winsock Problem [Archive] - C Board

PDA

View Full Version : Winsock Problem


(TNT)
07-08-2003, 12:48 PM
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:


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

Bubba
07-08-2003, 12:51 PM
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:

(TNT)
07-08-2003, 12:55 PM
Dam, sorry i never noticed that board, :rolleyes: can someone please move this

Xei
07-08-2003, 02:12 PM
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.

(TNT)
07-08-2003, 02:32 PM
Hi thanks do u have any tutorials on sock_streams or can you reccomend any good books covering them in detail,

Thanks
TNT

stovellp
07-08-2003, 08:26 PM
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).