March 15th, 2004, 10:11 AM
HELP:Can connect to server but server didnt receive sent data
server is using MFC socket class on win2K
client using sockets on solaris 2.3
I cant seem to receive anything at Server side coz I put breakpoints in OnReceive() & Receive() of the sock function.
connection is ok coz server side shows connected IP address n port on the application window, just that no data received.
This is the CLIENT side
connectServer(&clientAddr,&sock); //see below
//fread data from a file to a buffer
connectServer(struct sockaddr_in *clientAddr, int *sock)
arr = "serverPC";
hp = gethostbyname(arr);
*sock = socket(AF_INET,SOCK_STREAM,0)
servAddr.sin_family = AF_INET;
servAddr.sin_port = htons(9000);
result = connect(*sock,&servAddr,sizeof(servAddr) );
omitted the err checking codes
any idea where went wrong?
server side code needed?
March 15th, 2004, 10:50 AM
Yes. Some code of server side might help.
Check the return value of the send() function on the client side. At least it can show how much data have been placed in the TCP buffer...
"UNIX is simple; it just takes a genius to understand its simplicity!"
March 15th, 2004, 03:02 PM
March 15th, 2004, 09:44 PM
server side goes like tis
void CSock::OnReceive(int nErrorCode)
// TODO: Add your specialized code here and/or call the base class
if (dataLength > 0&& dataLength < 100000) //Just to make sure the client doesn't crash the server)
byte* message = new byte[dataLength+1];
int nRec = Receive(message,dataLength);
message[nRec] = '\0';
March 18th, 2004, 03:29 AM
attached the server n client code
March 22nd, 2004, 02:34 AM
I just need to implement a listening socket that can accept and receive data.
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.