I'm going to write an
You can use both a
Thread or an
AsyncTask, just chose one of the two based on your needs (if you provide more details about the task you need to perform I might be able to help you more specifically).
Handler class is not meant to be used to run asynchronous tasks (like
Handler instance is used to allow communication between two threads, for instance, if you decide to use the
Thread over the
Handler class will help you with data exchange between your UIThread and the Thread that handles the socket.
AsyncTasks are perfect for working as a Client. If what you need is opening a Server socket you should forget about those and try to have a look at the
Service and choose between
AsyncTask are meant to perform a specific job in a relatively little time. To open a server, which will need to stay opened for (possibly) a long time that's not the class you need.
I'd take a look at the
Service because it provides some useful methods to interact with the Android application lifecycle.