P
Pep
I use the following code to provide the socket communications for a
client/server application. At this point the main thread has accepted a
client socket connecti0on over the server socket and has spawned a client
thread that services the request via this code.
=========================================================================
try
{
pw = new PrintWriter(clientSocket.getOutputStream(),true); // get the
clients output stream
br = new BufferedReader(new
InputStreamReader(clientSocket.getInputStream())); // get the client input
stream
String jsonPacket = br.readLine(); // read JSON packet from client
processJSON(jsonPacket); // process the JSON request packet
pw.close(); // close the clients output stream
br.close(); // close the clients input stream
}
catch (Throwable e)
{
System.out.println("Error " + e.getMessage());
e.printStackTrace();
}
=========================================================================
So if I connect to this server application using telnet I get an instant
response from the above code. However, if I connect to this code from a C++
application using berkley sockets, I get an instant connection but have
seen from well placed prinln statements after the creation of the pw and br
streams that the actual reading takes around 181 seconds!
What could be the reason for this lag in the C++ originated communications
compared to the instant telnet origibated communications response?
TIA,
Pep.
client/server application. At this point the main thread has accepted a
client socket connecti0on over the server socket and has spawned a client
thread that services the request via this code.
=========================================================================
try
{
pw = new PrintWriter(clientSocket.getOutputStream(),true); // get the
clients output stream
br = new BufferedReader(new
InputStreamReader(clientSocket.getInputStream())); // get the client input
stream
String jsonPacket = br.readLine(); // read JSON packet from client
processJSON(jsonPacket); // process the JSON request packet
pw.close(); // close the clients output stream
br.close(); // close the clients input stream
}
catch (Throwable e)
{
System.out.println("Error " + e.getMessage());
e.printStackTrace();
}
=========================================================================
So if I connect to this server application using telnet I get an instant
response from the above code. However, if I connect to this code from a C++
application using berkley sockets, I get an instant connection but have
seen from well placed prinln statements after the creation of the pw and br
streams that the actual reading takes around 181 seconds!
What could be the reason for this lag in the C++ originated communications
compared to the instant telnet origibated communications response?
TIA,
Pep.