I am attempting to make a chatroom as my first program that communicates between computers. I am having trouble setting up the Server Socket Though. My program stops when it tries to set up.
Here are my variables
private JTextField textArea;
private ServerSocket servSock;
private Socket sock;
private BufferedReader buff;
private PrintStream output;
private String allMessages;
private JTextArea messages;
private String user;
I call this code
private void setUpServer() {
// TODO Auto-generated method stub
System.out.println ("Seting up Server");
try {
servSock = new ServerSocket (9999);
sock = servSock.accept();
buff = new BufferedReader (new InputStreamReader (sock.getInputStream()));
output = new PrintStream (sock.getOutputStream());
System.out.println ("Trying");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println ("failed");
}
}
It prints out "Setting up Server" and then it freezes. It doesn't give me any errors or anything. What is the problem?
Thanks for your help