How to run a server socket in an android app to connect other apps as clients

Is there any way to create a local multiplayer game like mini militia?
How to create a server socket inside the app ?

Suggestions will be most helpful.
Thanks