title: Socket connection test, not working and receive data from hyperterminal
body: <ol>
  <li>I am creating a socket connection in android eclipse for receiving data first i need to test the connection but the page is not opening on my app, i use a listactivity for my classes.</li>
  <li>I want to receive data from my pc(hyperterminal), i have connected a hardware device to my computer which behaves like a router and i want to connect my android phone to the router via Wifi and receive data on my phone as i type on the hyperterminal.</li>
  </ol>
  
  <p><code>package com.exa.bullseye;</code></p>
  
  <pre><code> import java.io.IOException;
   import java.net.InetAddress;
   import java.net.Socket;
   import java.net.UnknownHostException;
   import android.app.Activity;
   import android.content.Intent;
   import android.os.Bundle;
   import android.os.Handler;
   import android.text.Editable;
   import android.text.TextWatcher;
   import android.view.View;
   import android.widget.Button;
   import android.widget.EditText;
   import android.widget.ScrollView;
   import android.widget.TextView;
   import android.widget.Toast;
   import java.io.InputStream;
   import java.io.OutputStream;
  
  public class WifiReceive extends Activity {
      EditText ip;
      EditText s_port;
      Button connect;
  
      public void onCreate(Bundle paramBundle)
        {
          super.onCreate(paramBundle);
          setContentView(R.layout.wifireceive);
          ip = ((EditText)findViewById(R.id.ip));
          s_port = ((EditText)findViewById(R.id.port));
  
   connect.setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View arg0) {
  
                  try {
              String address = ip.getText().toString();
  
  
              InetAddress addr = InetAddress.getByName(address);
              int port = Integer.parseInt(s_port.getText().toString());
  
              // Creates a stream socket and connects it to the specified port
              // number at the specified IP address. Blocks until the connection succeeds.
  
              Socket socket = new Socket(addr, port);
  
  
  
              Toast.makeText(getApplicationContext(), "Socket Connected",
                      Toast.LENGTH_LONG).show();
              socket.close();
  
          }
          catch (UnknownHostException e) {
              Toast.makeText(getApplicationContext(), "Host not found",
                         Toast.LENGTH_LONG).show();
          }
          catch (IOException ioe) {
              Toast.makeText(getApplicationContext(), "I/O Exception",
                         Toast.LENGTH_LONG).show();
          }   
  
      }
   });
        }
  }
  </code></pre>