I would use Socket and ServerSocket for the server class. In the first group of code, your
ServerSocket s = new ServerSocket(1234);
is fine. To make the process easier for me, I globalized the Socket for the class
class Server{
private Socket connection;
private ObjectOutputStream output;
private ObjectInputStream input;
Then in a while loop, have the server connection listening
connection = server.accept();
You also want have, in the loop, a call to a method that establishes the streams and throws IOException
private void streams() throws IOException{
output=new ObjectOutputStream(connection.getOutputStream());
output.flush();
input=new ObjectInputStream(connection.getInputStream());
}
Now, for sending data (I have only done strings) you want to create a method.
private void send(String or_variable){
try{
output.writeObject("String" + or_variable);
output.flush();
}
catch(IOException ioException){
}
}
}