Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.InputStreamReader;
- import java.io.PrintWriter;
- import java.net.ServerSocket;
- import java.net.Socket;
- public class Server {
- public static void main(String[] args) {
- try {
- System.out.println("waiitng for clients");
- ServerSocket ss = new ServerSocket(9806);
- Socket socket = ss.accept();
- System.out.println("Connection established");
- BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
- String s = in.readLine();
- PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
- out.println("Server says: " + s);
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement