public int receive(byte[] data) {
        int bytesRead = 0;
        try {
            if (senderSocket == null) {
                senderSocket = tcpReceiverSocket.accept();
                in = senderSocket.getInputStream();
                out = senderSocket.getOutputStream();
            }
            if (in != null) {
                bytesRead = in.read(data);
                if (bytesRead > 0) {
                    Console.log("[TCP] data received.");
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return bytesRead;
    }