Android client sends string to server. Server will acknowledge a connection from device, and on the correct port but that is it..What should happen is the string is printed on the server console.
For reference, I've created the exact same client, without running it inside an android app and it works fine, so that leads me to believe I'm missing something on the android side of things. Can anyone offer a suggestion as to fix this problem. Many thanks.
Client code:
public class ObjectTestActivity extends Activity {
Button submit;
TextView tv;
private String name = "Hello Android";
private DataOutputStream dos;
private DataInputStream dis;
private final int PORT = 3000;
Button send;
InetAddress host;
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
send = (Button) findViewById(R.id.send);
tv = (TextView) findViewById(R.id.tv);
try{
host = InetAddress.getLocalHost();
Socket socket = new Socket("xx.xx.xxx.xxx", PORT);
dos = new DataOutputStream(socket.getOutputStream());
dis = new DataInputStream(socket.getInputStream());
}catch(UnknownHostException e){}
catch(IOException e){}
}
public void onClick(View view){
try{
dos.writeUTF(name);
dos.flush();
dis.close();
dos.close();
}catch(IOException e){}
}