H
happyvalley
Hi,
don't know if it is the place to ask this question
I have a c++ server and a java client communicate via socket
in Java client
// create a client socket
Socket clientSocket = new Socket("localhost", 27015);
PrintWriter out = new PrintWriter(clientSocket.getOutputStream(),
true);
String userInput = "amsg";
System.out.println("send to server:" + userInput.length() + " :" +
userInput);
out.println(userInput);
in c++ server
// code to starup the connection
int recvbuflen = 255;
char recvbuf[255];
int iResult = recv(ClientSocket, recvbuf, recvbuflen, 0);
cout<<"iResult = "<<iResult<<endl;
the msg sendout in java client "amsg" is 4, while, in the c++ server,
it says the msg length = 6.
it always +2.
when I send the msg from a java client to a java server via socket,
there is no such problem
any suggestion. thanks
don't know if it is the place to ask this question
I have a c++ server and a java client communicate via socket
in Java client
// create a client socket
Socket clientSocket = new Socket("localhost", 27015);
PrintWriter out = new PrintWriter(clientSocket.getOutputStream(),
true);
String userInput = "amsg";
System.out.println("send to server:" + userInput.length() + " :" +
userInput);
out.println(userInput);
in c++ server
// code to starup the connection
int recvbuflen = 255;
char recvbuf[255];
int iResult = recv(ClientSocket, recvbuf, recvbuflen, 0);
cout<<"iResult = "<<iResult<<endl;
the msg sendout in java client "amsg" is 4, while, in the c++ server,
it says the msg length = 6.
it always +2.
when I send the msg from a java client to a java server via socket,
there is no such problem
any suggestion. thanks