I am connecting to a server on my network written in C#. The data sent from the android device is recieved
by the server and a reply is succesfully sent but the android code timesout and never gets the return data.
I have tested that the C# server can communicate and reply with a C# client.
I have studied the network traffic using Wireshark when using both the C# server-android client and C# server-C#
client and it appears that the android device acknowledges(ACK) the reply data but my code never recieves it.
I have the code running in a thread so running it on Android 4.0 doesn't error out but I have tried running it on
Android 2.2 with exactly the same behaviour(or lack of it). Also I have run it on 2 different android devices.
(AndroidManifest.xml)
(My Code)
by the server and a reply is succesfully sent but the android code timesout and never gets the return data.
I have tested that the C# server can communicate and reply with a C# client.
I have studied the network traffic using Wireshark when using both the C# server-android client and C# server-C#
client and it appears that the android device acknowledges(ACK) the reply data but my code never recieves it.
I have the code running in a thread so running it on Android 4.0 doesn't error out but I have tried running it on
Android 2.2 with exactly the same behaviour(or lack of it). Also I have run it on 2 different android devices.
(AndroidManifest.xml)
Code:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
(My Code)
Code:
private static final int TCP_SERVER_PORT = 3000;
private static final String TCP_SERVER_IP = "192.168.1.55";
try {
SocketAddress socketAddress = new InetSocketAddress(serverAddr, TCP_SERVER_PORT);
Socket s2 = new Socket();
s2.connect(socketAddress);
BufferedReader in = new BufferedReader(new InputStreamReader(s2.getInputStream()));
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(s2.getOutputStream()));
//send output msg
String outMsg = "TCP connecting to " + TCP_SERVER_PORT + System.getProperty("line.separator");
out.write(outMsg);
out.flush();
//accept server response
String inMsg = in.readLine();
s2.close();
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}