0

I am sending some characters through socket in java and receiving it in C++ code. It works fine for every character but when i send a semicolon (;), It is not received at the other end. Only semicolon gets dropped. I am not understanding this, its strange and weird. Can anyone please help

Java code (Client)

I call this function and pass string as an argument which contains all the characters i want to send along with (;).

public void send_string(Socket socket, String str) throws IOException
{
DataOutputStream out = new DataOutputStream(socket.getOutputStream());
out.writeBytes(str);
out.flush();
}

C++ code (server)

int main()
{
std::string recvData = ""; 
try
{
ServerSocket server ( 30000 );
while ( true )
{
ServerSocket new_sock;
server.accept ( new_sock );
try
{
while ( true )
{
new_sock >> recvData;
// processing of received data, here i don't see (;) which was sent
}
}
catch(SocketException &e)
{
cout<<e.description().c_str();
}
}
catch(SocketException &e) 
{
cout<<e.description().c_str();
}
4

0 に答える 0