I am trying to write a simple message to a remote Server using Socket in Android, The remote server was provided to me, here is my attempt, it stops at out.write
@Override
protected String doInBackground(String... params) {
String comment = params[0];
Log.i(TAG_STRING, "Comment is " + comment);
String response = null;
Socket socket = null;
try {
socket = new Socket("www.regisscis.net", 8080);
DataOutputStream out = new DataOutputStream(socket.getOutputStream());
DataInputStream in = new DataInputStream(socket.getInputStream());
Log.i(TAG_STRING, "Calling Write");
out.writeBytes(comment);
out.flush();
String resposeFromServer = in.readUTF();
out.close();
in.close();
response = resposeFromServer;
socket.close();
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return response;
}
Would anyone know what I am doing wrong,