March 15th, 2004, 10:11 AM
#1
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
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?
March 15th, 2004, 10:50 AM
#2
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
#3
March 15th, 2004, 09:44 PM
#4
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);
}
March 18th, 2004, 03:29 AM
#5
attached the server n client code
anyone...?
Attached Files
March 22nd, 2004, 02:34 AM
#6
I just need to implement a listening socket that can accept and receive data.
Anyone?
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width