-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathServer.java
More file actions
26 lines (22 loc) · 764 Bytes
/
Server.java
File metadata and controls
26 lines (22 loc) · 764 Bytes
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
import java.io.IOException;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Scanner;
public class Server {
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
final int PORT = 9001;
ServerSocket server = new ServerSocket(PORT);
System.out.println("Server Start and Waiting for the Client");
Socket socket = server.accept();
System.out.println("Here Comes the Client....");
System.out.println("Enter the Message Send to the Client");
String msg = new Scanner(System.in).nextLine();
OutputStream os = socket.getOutputStream();
os.write(msg.getBytes());
System.out.println("Message Send to the Client....");
os.close();
socket.close();
}
}