-
Notifications
You must be signed in to change notification settings - Fork 0
/
Server.java
30 lines (27 loc) · 929 Bytes
/
Server.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package TechTalk;
import java.net.*;
import java.io.*;
public class Server {
private Socket socket = null;
private ServerSocket server = null;
private DataInputStream input = null;
Server(int port)throws IOException {
server = new ServerSocket(port);
System.out.println("Server Started..");
System.out.println("Waiting for Client.....");
socket = server.accept();
System.out.println("Client Connected...");
input = new DataInputStream(new BufferedInputStream(socket.getInputStream())) ;
String message ="";
while(!message.equals("bye")) {
message = input.readUTF();
System.out.println(message);
}
socket.close();
server.close();
input.close();
}
public static void main(String[] args) throws IOException{
new Server(1000);
}
}