Hello.
I have simple soccer game in development, 2 players, goalie and one goal. Start menu of the game is shown in swing with pictures, while animation starts with click on start and it’s in a seperate thread shown also with pictures but with active rendering. I now plan to implement networking, server mode and client mode. I read tutorials about sockets and I know how to start a simple server that waits for connection and reads lines from buffered input stream (and responds…). I have a question now, do I need to put server class in a seperate thread so it can listen for data unbothered or do I put listening code directly into game loop? Also have question about readLine(), code:
while ((data_in_line = data_in.readLine()) != null) {
// process data_in_line...
if (data_in_line.equals("Bye."))
break;
}
When data comes in does the buffer stores it and waits for program to read it or program must listen all the time so it wouldn’t miss any data that is received? Like I get a message, then another one, and then try to read what is sent to me, will I read only last message or both? Can someone please explain this to me in a few sentances or point me to a tutorial?
Thank you.