java - Android to android TCP connection failed -
i'm trying make tcp connection between android phones in same subnet. connection works when use android phone server , android emulator client. when switch emulator other android phone timeout. android phones in same local network(192.168.0.0/24).
client script:
s = new socket(); s.connect(new inetsocketaddress(ip, tcp_server_port), 10000); dataoutputstream dos = new dataoutputstream(s.getoutputstream()); dos.writeutf("coord"); s.close();
server script:
while(!end){ //server waiting client here, if needed socket s = ss.accept(); datainputstream dis = new datainputstream(s.getinputstream()); string msg_received = dis.readutf(); log.i("gauta",msg_received); if(msg_received.equals("coord")) { //some work..... } s.close(); if (quit){ end = true; } } ss.close(); } catch (unknownhostexception e) { // todo auto-generated catch block e.printstacktrace(); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); }
Comments
Post a Comment