Skip to content

Instantly share code, notes, and snippets.

@jwtea
Created May 31, 2014 19:45
Show Gist options
  • Save jwtea/0136df446426a50c5fec to your computer and use it in GitHub Desktop.
Save jwtea/0136df446426a50c5fec to your computer and use it in GitHub Desktop.
package wiflyServer;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
public class Server {
static gui goo; //Create a new Gui object
public static Socket socket; //Create a new socket object
public static void conn(){
try {
ServerSocket clientSocket = new ServerSocket(2042); //Set up a server socket listening on the port 2042
System.out.println("server est");
socket = clientSocket.accept(); //If a connection is accepted assign it to the socket
System.out.println("client connected");
clientSocket.close(); //Close the server socket as a socket has been assigned
goo = new gui(socket); //Construct the GUI passing the socket object
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void main( String args[] )
{
conn(); // call the conn method to start a connection
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment