Note that there are some explanatory texts on larger screens.

plurals
  1. POConnecting 2 Emulator instances In Android
    primarykey
    data
    text
    <p>I want to create a Server and a Client in 2 Emulator to write and read data. I write code for Server :</p> <pre><code>public class ServerActivity extends Activity { /** Called when the activity is first created. */ private ServerSocket serverSocket = null; private TextView tv; public static final int SERVERPORT = 4444; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); tv= (TextView) findViewById(R.id.myTextView); try { Connect(); } catch (IOException e) { // TODO Auto-generated catch block tv.setText("Not connected"); e.printStackTrace(); } } public void Connect() throws IOException { serverSocket = new ServerSocket(); serverSocket.bind(new InetSocketAddress("10.0.2.15", 4444)); while(true) { Socket socket = serverSocket.accept(); tv.setText("Connected..."); } } </code></pre> <p>And code for Client</p> <pre><code>public class ClientActivity extends Activity { /** Called when the activity is first created. */ private Button bt; private TextView tv; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); bt = (Button) findViewById(R.id.myButton); tv = (TextView) findViewById(R.id.myTextView); bt.setOnClickListener(new OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub try { Socket socket = new Socket("10.0.2.2", 4445); } catch (UnknownHostException e) { // TODO Auto-generated catch block tv.setText("Error1"); e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block tv.setText("Error2"); e.printStackTrace(); } } }); } } </code></pre> <p>I set up a redirection :</p> <pre><code>telnet localhost 5554 redir add tcp:4445:4444 </code></pre> <p>But it's not connecting....Please help me. I appreciate it.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload