I have a small C++ server and a java client. I send data from the client to the server. The recv() function of the server side does not receive the the data. I receive the size -1. But the otherway about works well (i.e. from server to the client). Here is my scaled down code.
Sever users the following read() to read data from the socket...
void read ( )
char buffer [ 100 ];
memset ( buffer, 0, 100 );
int receiveSize = ::recv ( mSocket, buffer, 100, 0 );
std::cout << "Received Size : " << receiveSize << std::endl;
//The recvSize is -1 above.
My Client uses the following simple java function to write the data to the socket:
public void writeValue(Socket requestSocket)
DataOutputStream dOut = new DataOutputStream(requestSocket.getOutputStream());
System.out.println("writing a char...");
catch (Exception exp)
1. Connection is perfer
2. Data sending from server to client is perfect
2. Problem is server receiving data from the client.
Can someone throw some light? BTW I work in a UNIX environment.