Skip to content

Instantly share code, notes, and snippets.

@falcore316
Created October 20, 2017 06:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save falcore316/9a58330292f5e8a8e4391f3d7147d814 to your computer and use it in GitHub Desktop.
Save falcore316/9a58330292f5e8a8e4391f3d7147d814 to your computer and use it in GitHub Desktop.
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