-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathServer.java
More file actions
29 lines (22 loc) · 714 Bytes
/
Copy pathServer.java
File metadata and controls
29 lines (22 loc) · 714 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
27
28
29
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 {
ServerSocket server = new ServerSocket(9001);
System.out.println("Waiting for the Client....");
Socket socket = server.accept();
System.out.println("Here Comes the Client");
System.out.println("Enter the Message to Send");
Scanner scanner = new Scanner(System.in);
String msg = scanner.nextLine();
OutputStream os = socket.getOutputStream();
os.write(msg.getBytes());
os.close();
socket.close();
scanner.close();
System.out.println("Data Sended....");
}
}