I usually don't program in Java, but I decided to write a simple client-server application just to figure how this works in Java.
When I run both server and client through eclipse - everything's fine, but when I run the client in my Android device through Android Studio - it doens't connect to the server.
Both running on same WIFI. Server IP is pc's LAN ip. Server listens on port 32323, client connects to 32323.
Server:
public class Server
{
    private int port;
    private ServerSocket serverSocket;
    private Socket client;
    public Server(int port)
    {
        this.port = port;
        try
        {
            serverSocket = new ServerSocket(port);
        }
        catch (Exception exception) {}
        try
        {
            client = serverSocket.accept();
            System.out.println("logged in");
        }
        catch (Exception exception) {}
    }
}
Client:
// The following line is written inside onCreate:
onlineClient = new OnlineClient(new byte[] {(byte) 192, (byte) 168, 1, 17}, 32323); 
public class OnlineClient
{
    private Socket socket;
    private PrintWriter writer;
    private BufferedReader reader;
    public OnlineClient(byte[] serverIP, int port)
    {
        try
        {
            socket = new Socket(Inet4Address.getByAddress(serverIP), port);
//          writer = new PrintWriter(socket.getOutputStream(), true);
//          reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
//          socket.setTcpNoDelay(true);
        }
        catch (IOException e) {}
    }
}
