Android Socket Programing Exception
<p>I was trying to send data from Android Studio using UDP but got an exception on the line  server.send(packet) is throwing exception ....
Here  is My code from mainActivity....</p>

<pre><code>    public void onClickLoginButton(View view) throws IOException
    {
        loginButton = (Button) findViewById(R.id.button);
        editText= (EditText) findViewById(R.id.editText);
        EditText editText1 = (EditText) findViewById(R.id.editText2);
        send=new byte[1024];
        receive=new byte[1024];




        send="login".getBytes();
            DatagramPacket packet2 = new DatagramPacket(send, send.length, InetAddress.getByName("192.168.10.9"), 1205);
             try {
                 server.send(packet2);
             }
             catch(Exception e)
             {

                 Log.d(getClass().getSimpleName(),"error");
             }

        String client = editText.getText().toString();
            send = client.getBytes();
            DatagramPacket packet = new DatagramPacket(send, send.length, InetAddress.getByName("192.168.10.9"), 1205);
            server.send(packet);

            String string = editText1.getText().toString();
            send = client.getBytes();
            DatagramPacket datagramPacket = new DatagramPacket(send, send.length, InetAddress.getByName("192.168.10.9"), 1235);
            server.send(packet);


            DatagramPacket packet1 = new DatagramPacket(receive, receive.length);
            server.receive(packet1);

        Log.d(getClass().getSimpleName(), "Connection failed"
                );



    }
}
</code></pre>

<p>Exception:</p>

<pre><code>29830/com.example.hamza.weekendmessanger E/AndroidRuntime: FATAL EXCEPTION: main java.lang.IllegalStateException: Could not execute method for android:onClick
</code></pre>