Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Client_Application {
- public static void main(String argv[]) throws Exception
- {
- while(true)
- {
- String sentence;
- String modifiedSentence;
- BufferedReader inFromUser = new BufferedReader( new InputStreamReader(System.in));
- Socket clientSocket = new Socket("localhost", 6789);
- DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream());
- BufferedReader inFromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
- sentence = inFromUser.readLine();
- outToServer.writeBytes(sentence + '\n');
- modifiedSentence = inFromServer.readLine();
- System.out.println("FROM SERVER: " + modifiedSentence);
- clientSocket.close();
- }
- }
- }
- public class Server_Application {
- public static void main(String argv[]) throws Exception
- {
- //System.out.println("This is Server Site");
- Scanner sc= new Scanner(System.in);
- String clientSentence;
- //String capitalizedSentence;
- ServerSocket welcomeSocket = new ServerSocket(6789);
- while(true)
- {
- Socket connectionSocket = welcomeSocket.accept();
- BufferedReader inFromClient =
- new BufferedReader(new InputStreamReader(connectionSocket.getInputStream()));
- DataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputStream());
- clientSentence = inFromClient.readLine();
- System.out.println("Received: " + clientSentence);
- clientSentence=sc.nextLine();
- //capitalizedSentence = clientSentence.toUpperCase() + '\n';
- outToClient.writeBytes(clientSentence+ '\n');
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement