android - Use TCP in Internet -
i'am use tcp connect android phone windows 7 pc. when i'am send message phone-pc in lan system work, i`am use system in internet down because android app send me "time out". why?
// host name can either machine name, such "java.sun.com", or // textual representation of ip address string host = "10.26.144.118"; int port = 20; try { socket socket = new socket(inetaddress.getbyname(host), port); bufferedreader reader = new bufferedreader( new inputstreamreader(socket.getinputstream())); printwriter writer = new printwriter(socket.getoutputstream(), true); // true auto flush writer.println("hello world"); myview.settext("send hello world"); } catch (exception e) { system.out.println("error" + e); myview.settext("error" + e); }
you looking port-forwarding
Comments
Post a Comment