Hi i want tcp-socket connection for connection with socket and take
response back:
public static String SERVERIP = "192.168.0.127";
// designate a port
public static final int SERVERPORT = 5675;
private void connectSocket() {
// TODO Auto-generated method stub
try {
InetAddress serverAddr = InetAddress.getByName(SERVERIP);//
10.66.3.44 is my pc' IP
Log.d("TCP", "C: Connecting...");
Socket socket = new Socket(serverAddr, SERVERPORT);
String message = "Hello from Client android emulator";
try {
Log.d("TCP", "C: Sending: '" + message + "'");
PrintWriter out = new PrintWriter( new BufferedWriter( new
OutputStreamWriter(socket.getOutputStream())),true);
out.println(message);
Log.d("TCP", "C: Sent.");
Log.d("TCP", "C: Done.");
} catch(Exception e) {
Log.e("TCP", "S: Error", e);
} finally {
socket.close();
}
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
Log.e("TCP", "C: UnknownHostException", e);
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
Log.e("TCP", "C: IOException", e);
e.printStackTrace();
}
}
Here my connection time out , how to check socket connection , what is
wrong entry here plz confirm me.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en