08-31-2010 01:15 AM
At the moment I can connect my device and simulator to my server using direct tcp with my IP and port. However when I write("Protocol Version 2\r\n"); my server receives the following number of bytes..
why does it only send 1 byte? then send 22.. Shouldn't it be consistent?
Solved! Go to Solution.
08-31-2010 02:59 AM
For the past couple hours i've been trying to think of the reason why the bytes arent consistent. It could be because TCP connection is losing data along the way. So i could implement my server to check the number of bytes received and compare it to the expected number of bytes required to the expected input. However i do not believe its due to the lose of data.
08-31-2010 02:37 PM
Ya see I thought so. I tried do what i mentioned above however i end up getting my string cut up. Heres my code. Im not sure why TCP only sends 1 byte and then 22. Even if i change the last line to write(_protocol, 0, _protocol.length());
// Variables and Fields private StreamConnection conn = null; private String _protocol = "Protocol Version 2"; private String _url = "socket://188.8.131.52:52468;deviceside=true"; // Create Socket Connection with Input/Output Writers conn = (StreamConnection)Connector.open(_url, Connector.READ_WRITE, false); InputStreamReader _in = new InputStreamReader(conn.openInputStream()); OutputStreamWriter _out = new OutputStreamWriter(conn.openOutputStream()); // Write to Server _out.flush(); _out.write(_protocol + "\r\n");