Socket connection android
<p>I am trying to open input and output streams in android but I'm not sure how to go about this. I have opened a socket connection in J2ME previously by using the following in the server:</p>

<pre><code>scn = (ServerSocketConnection) Connector.open("socket://:5000");     
String myAddress = scn.getLocalAddress();
si.setText("My address: " + myAddress);
// Wait for a connection.
sc = (SocketConnection) scn.acceptAndOpen();
//Get address of socket connection
String yourAddress = sc.getAddress();
si.setText("Connected to: " + yourAddress);
is = sc.openInputStream();
os = sc.openOutputStream();
</code></pre>

<p>Now I want to put this into android but its not letting me open input and output streams and also I had to change a few things which I'm not sure would work in the same way.</p>

<pre><code>scn = (ServerSocket) Connector.open("socket://:5000");    
    String myAddress = scn.getLocalAddress();
        Connection.setText("My address: " + myAddress);
        // Wait for a connection.
        Socket sc = scn.accept();
        //Get address of socket connection
        String yourAddress = sc.getAddress();
        Connection.setText("Connected to: " + yourAddress);
        is = sc.openInputStream();
        os = sc.openOutputStream();
</code></pre>

<p>The errors which I am getting in android are with the Connector, getLocalAddress, getAddress and openInput and OutputStreams. </p>

<p>I would appreciate any help on this, as I am having great difficulty setting this up in android. </p>

<p>Thanks</p>

<p>Edit: </p>

<p>I have changed the Android code to this: </p>

<pre><code>ServerSocket scn = new ServerSocket(5554);    
    InetAddress myAddress = scn.getInetAddress();
        Connection.setText("My address: " + myAddress);
        // Wait for a connection.
        Socket sc = scn.accept();
        //Get address of socket connection
        InetAddress yourAddress = sc.getInetAddress();
        Connection.setText("Connected to: " + yourAddress);
        is = sc.openInputStream();
        os = sc.openOutputStream();
</code></pre>

<p>Which compiles fine but I get an error on:</p>

<pre><code> is = sc.openInputStream();
        os = sc.openOutputStream();
</code></pre>

<p>Is there another way to open input and output streams in android?</p>

<p>Thanks.</p>
