Android TCP Client / Server Crashes
===

Hello I'm very new to TCP and I want to build a multiplayer game. But I'm encountering a fatal error that crashes my application everytime I open the 'Client.java' class.

I get a android.os.NetworkOnMainThreadException, I've added the INTERNET permission in android manufest. I go to this class from another using Intent and yes I have setOnClickListener(this); there and added Activity to the manufest so it doesn't crash because of that. 
And If this is a good idea, im building the TCP server and client both within the application, then how am I going to make it a public host? Like I need to pay for a host and then use the ip/port in the server and client?

Anyway here's the code:

    package com.theory.game;
    import java.io.BufferedReader; 
    import java.io.IOException; 
    import java.io.InputStreamReader; 
    import java.io.PrintWriter; 
    import java.net.Socket; 
    import java.util.Scanner; 
    import android.app.Activity; 
    import android.os.Bundle; 
    import android.view.View; 
    import android.widget.Button; 
    import android.widget.EditText; 
    import android.widget.TextView; 
 
    public class Client extends Activity { 
    /** Called when the activity is first created. */ 
    Scanner scanner = new Scanner(System.in); 
    //StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); 


    @Override 
    public void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState); 
        setContentView(R.layout.client); 
        //StrictMode.setThreadPolicy(policy);  
        final EditText msg = (EditText) findViewById(R.id.etMsg); 
        Button send = (Button) findViewById(R.id.bSend); 
        final TextView convo = (TextView) findViewById(R.id.tvConvo); 
        final TextView status = (TextView) findViewById(R.id.tvStatus); 
 
        try { 
            send.setOnClickListener(new View.OnClickListener() { 
 
                Socket s = new Socket("10.0.2.2", 8080); 
                String message = msg.getText().toString(); 
 
                @Override 
                public void onClick(View v) { 
                    status.setText("..."); 
                    PrintWriter outp = null; 
                    BufferedReader inp = null; 
                    status.setText("Established connection.."); 
                    String serverMsg = null; 
 
                    try { 
                        outp = new PrintWriter(s.getOutputStream(), true); 
                        inp = new BufferedReader(new InputStreamReader(s.getInputStream())); 
                        serverMsg = inp.readLine(); 
                    } catch (IOException e) { 
                        e.printStackTrace(); 
                    } 
                    convo.append(serverMsg + "\n"); 
 
                    if (message != null) { 
                        if (msg.getText().toString().trim() == "QUIT") { 
                            try { 
                                s.close(); 
                            } catch (IOException e) { 
                                e.printStackTrace(); 
                            } 
                            status.setText("Disconnected from server."); 
 
                        } else { 
                                try { 
 
                                    convo.append(message + "\n"); 
                                    outp.println(message);  
                                    serverMsg = inp.readLine(); 
                                    convo.append(serverMsg + "\n"); 
                                } catch (IOException e) { 
                                    e.printStackTrace(); 
                                } 
                        } 
 
                    } 
                    else 
                        status.setText("Problem in connection..!"); 
                } 
            }); 
        } catch (IOException e) { 
            e.printStackTrace(); 
        } 
    } 
}