I need my server to stay connected to the server. Does anyone know how to do this? Or post links tutorials anything?
Also it says when it restarts 'could not accept client' so how would I clear everything and make it accept it?
I need my server to stay connected to the server. Does anyone know how to do this? Or post links tutorials anything?
Also it says when it restarts 'could not accept client' so how would I clear everything and make it accept it?
Server code:
For your server side code, do a loop wrapping the accept call. For the accepted socket that is created create a new thread, so that the next accept will be called right away.
On server startup you may also want to use the SO_REUSEADDR flag. That way if you had a crash, or even a fast restart of the program, then your server will be able to use the same port again without a problem.
Client code:
For your client code you would just check for a socket error and if that occurs just establish a new connection.
Other resources:
Other options:
Instead of plain bsd-style sockets, you could also try using boost asio for easier socket programming. You could check out their examples page.