java - Android emulator(client) to phone(server) socket connection -


i'm attempting connect emulator(client) , phone(server) through tcp/ip socket connection. somehow never works, works fine if try connect emulator (as client / server) internal java program (as client / server), socket connection works fine phone applications that's not on emulator. thought has port forwarding i've tried:

sourced how can forward localhost ip-address android emulator

telnet localhost 5554 redir add tcp:1337:12345 

but when test client side port number 1337 , server side 12345, still doesn't work, server code doesn't .accept() client's request.

following client(emulator) , server(phone) code accepting , setting io streams

client:

server_ip local ip address

connection = new socket(server_ip, port); private void setupstreams() throws ioexception { output = new objectoutputstream(connection.getoutputstream()); output.flush(); input = new objectinputstream(connection.getinputstream()); } 

server:

that's accepting user private void acceptinguser() {

 try { ss = new serversocket(port, 10); connection = ss.accept(); connected = true; osm.updateinchatstatus(1); } catch (ioexception e) { // todo auto-generated catch block log.i("serv", "wasn't able connect clients!: " + e); } } 

and setting stream pretty similar client's one. in advance ur advices , solutions.

to access network connection, need set permission in androidmanifest.xml

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.bosch.adx.esidroid"> <uses-permission android:name="android.permission.internet" /> <application -- 

Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -