Created
October 20, 2017 06:55
-
-
Save falcore316/9a58330292f5e8a8e4391f3d7147d814 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.net.*; | |
import java.util.*; | |
public class Server | |
{ | |
public static void main (String args[]) | |
{ | |
String line; | |
Scanner input; | |
Formatter output; | |
Socket connection; | |
ServerSocket serversocket; | |
try | |
{ | |
serversocket = new ServerSocket(10000); | |
connection = serversocket.accept(); | |
System.out.println("waiting for input"); | |
input = new Scanner(connection.getInputStream()); | |
output = new Formatter (connection.getOutputStream()); | |
line = input.nextLine(); | |
System.out.println("String reveived from client " + line); | |
output.flush(); | |
} | |
catch (IOException ioe) | |
{ | |
ioe.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment