// JP opened flex table

Click to See Complete Forum and Search --> : HELP:Can connect to server but server didnt receive sent data


hamham
March 15th, 2004, 10:11 AM
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
send(sock,buffer,size0f(buffer),0); //


connectServer(struct sockaddr_in *clientAddr, int *sock)
{
arr[1] = "serverPC";

hp = gethostbyname(arr[1]);

*sock = socket(AF_INET,SOCK_STREAM,0)
servAddr.sin_family = AF_INET;
bcopy(hp->h_addr,&servAddr.sin_addr, hp->h_length);
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?

dimm_coder
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...

Andreas Masur
March 15th, 2004, 03:02 PM
[Moved thread]

hamham
March 15th, 2004, 09:44 PM
hmmm...
server side goes like tis

Server.Create(9000,SOCK_STREAM,myIP);
Server.Listen();

CSock::OnAccept(int nErrorCode)
{
Accept(socket,0,0)
.......
}

void CSock::OnReceive(int nErrorCode)
{

// TODO: Add your specialized code here and/or call the base class

long dataLength;
Receive(&dataLength, 4);

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';

//::SendMessage(hParent,WM_RECEIVE_MESSAGE,(WPARAM)message,(LPARAM)nSocket);
}

CSocket::OnReceive(nErrorCode);
}

hamham
March 18th, 2004, 03:29 AM
attached the server n client code

anyone...?

hamham
March 22nd, 2004, 02:34 AM
I just need to implement a listening socket that can accept and receive data.

Anyone?

//JP added flex table