c++ socket send don't transmit CR and LF
Is there any solution to send CR (0x0D) and LF (0x0A) by socket?
I've got some data like the char buffer below. I want to have a solution
where I'm able to send some binary data (range should be full 8Bit = 0x00
to 0xFF).
The socket "connectedSocket" is successfully set up.
char bufSend[] = {0x01, 0x01, 0x0A, 0x04, 0x44, 0x0D, 0x12};
ret = send(connnectedSocket, bufSend, 7, 0);
if(SOCKET_ERROR == ret) {
printf("Error: send, code: %d\n", WSAGetLastError());
return 1;
}
I've got the return message: 10053 = WSAECONNABORTED
If I change the data to something without 0x0A and 0x0D there is no error.
The client is programmed in java:
if (socket.isConnected()) {
out = new PrintWriter(new BufferedWriter(
new OutputStreamWriter(socket.getOutputStream())), true);
in = new BufferedReader(new InputStreamReader(
socket.getInputStream()));
// start connection
out.println(CONNECTION_BEGIN);
inMessage = in.readLine();
System.out.println("data length: " + inMessage.length());
No comments:
Post a Comment