static void handleUDP(DatagramSocket udpSocket) throws IOException {
        while (true) {
            //will represent the received data as bytes
            byte[] receiveData = new byte[1024];
            //sent data as bytes
            byte[] sendData = new byte[1024];
            //represent received packet
            DatagramPacket receivePacket = new DatagramPacket(receiveData,
                    receiveData.length);
            //waits until a packet is received form the client
            udpSocket.receive(receivePacket);
            //receive client string by extracting the data from the received packet
            clientString = new String(receivePacket.getData());
            System.out.println(receivePacket.getAddress().toString() + ":" + receivePacket.getPort() + " sent this message: " + clientString);
            //get the client ip and port
            InetAddress clientIPAddress = receivePacket.getAddress();
            int port = receivePacket.getPort();
            //build the data to be sent to the client
            sendData = clientString.getBytes();
            DatagramPacket sendPacket = new DatagramPacket(sendData,
                    sendData.length, clientIPAddress, port);
            //send data to client
            udpSocket.send(sendPacket);
        }
    }

}

/*represents a single tcp connection from a client*/
class TcpSendThread extends Thread {
    //message sent form the client
    private static String clientString;
    private Socket socket = null;

    public TcpSendThread(Socket socket) {
        super("TcpSendThread");
        this.socket = socket;
    }

    public void run() {
        try {
            handleTCP(socket);
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

    /*responsible for handling all TCP connections to the server*/
    static void handleTCP(Socket clientSocket) throws IOException {
        //get socket
        Socket connectionSocket = clientSocket;
        //input stream from client
        BufferedReader inFromClient = new BufferedReader(
                new InputStreamReader(connectionSocket.getInputStream()));
        //output stream to client
        DataOutputStream outToClient = new DataOutputStream(
                connectionSocket.getOutputStream());
        //message received from the client
        clientString = inFromClient.readLine() + "\n";
        System.out.println(connectionSocket.getInetAddress().toString() + ":" + connectionSocket.getPort() + " sent this message: " + clientString);
        //sent the modified message to client
        outToClient.writeBytes(clientString);
    }