TCP Chat Application
TCP Chat Application
NAME: SATHIYA A K
ROLL NO: 21CS149
CODE:
FILE: TCPClient.java
import java.io.*;
import java.net.*;
try {
// Create a socket to connect to the server
Socket socket = new Socket(serverAddress, serverPort);
} catch (IOException e) {
e.printStackTrace();
}
}
}
FILE:TCPServer.java
import java.io.*;
import java.net.*;
} catch (IOException e) {
e.printStackTrace();
}
}
}
OUTPUT:
while (true) {
System.out.print("Enter a message to send to the server (or
'exit' to quit): ");
String message = userInput.readLine();
if (message.equals("exit")) {
break;
}
// Process the received data (you can add your logic here)
OUTPUT: