-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServer.java
More file actions
28 lines (23 loc) · 725 Bytes
/
Server.java
File metadata and controls
28 lines (23 loc) · 725 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
package Networking;
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 Client");
Socket socket = server.accept();
System.out.println("Client Join the Server");
OutputStream os = socket.getOutputStream();
System.out.println("Enter the Data Send to Client");
Scanner scanner = new Scanner(System.in);
String data = scanner.nextLine();
os.write(data.getBytes());
os.close();
socket.close();
scanner.close();
System.out.println("Data Send....");
}
}