Android client Socket throws SocketException:
<p>I am trying to implement java socket client in android and my server is my laptop. I want my android mobile to connect to laptop by java socket. But i am getting exception on client side: "SocketException" and it looks to me because of the socket() call not able to create socket properly. Below is my android client side code for review. Is there any solution to the resolve the exception:</p>

<pre><code>public class SimpleActivityExampleActivity extends Activity  {

/** Called when the activity is first created. */
private String usrName;
private String vendorName;
private String message;
public Socket socket;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
  }


public void submitTheForm(View view) {

    final EditText edittext1 = (EditText) findViewById(R.id.editText1);
    final EditText edittext2 = (EditText) findViewById(R.id.EditText01);
    final EditText edittext3 = (EditText) findViewById(R.id.editText2);
    usrName = edittext1.getText().toString(); 
    vendorName = edittext2.getText().toString();
    message = edittext3.getText().toString();
    message = usrName+ "," + vendorName + "," + message;

    byte[] msg = message.getBytes();
    try {
    InetAddress serverAddr = InetAddress.getByName("192.168.1.2");
        Log.d("ClientActivity", "C: Connecting...");

        socket = new Socket(serverAddr, 2200);
    socket.getOutputStream().write(msg);
    socket.getOutputStream().flush();
    } catch (UnknownHostException e) {

        Toast.makeText(SimpleActivityExampleActivity.this, "unknownhostException", Toast.LENGTH_SHORT).show();
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (SocketException e) {
        // TODO Auto-generated catch block

        Toast.makeText(SimpleActivityExampleActivity.this, "Sockexception", Toast.LENGTH_SHORT).show();
        e.printStackTrace();
    }catch (IOException e) {
        // TODO Auto-generated catch block
        //System.out.println("in IOexception for sure");
        Toast.makeText(SimpleActivityExampleActivity.this, "IOexception", Toast.LENGTH_SHORT).show();
        e.printStackTrace();
    }
    catch (Exception e){
        Toast.makeText(SimpleActivityExampleActivity.this, "Exception", Toast.LENGTH_SHORT).show();
        e.printStackTrace();
    }finally {
        if(socket != null){
            try {
                socket.close();

            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }
}
} 
</code></pre>

<hr>

<p>submitTheForm() function is invoked on a button click from main.xml file "android:onClick =  "submitTheForm"</p>
