((TCP or UDP) or (TCP and UDP)) ??
i am currently thinking about how to use udp while not wasting up my code. i realized that it is very hard with udp to do the connecting and disconnecting stuff. this i am currently doing:
- the server waits for packets (in a thread)
- every packet has an id (connection/disconnection requests ...)
- if the packet is a connection packet, then a client wants to connect. so i check my list of currently connected clients if this address(with udp i have no socket for a client) is already connected, if not put it to the list and send a connection_ok packet to the client.
is this a good idea?
and how do i check if a client has disconnected? not in all cases he sends a disconnection request (eg computer crashed).
or would it be a good idea to use both:
- tcp for the important stuff (connection/disconnection)
- udp for fast and not so important stuff like player postions which are updated very often in one second
Use both.
The client always sends a packet to the server and the server responds. Rarely will it be the other way round.
Keep a timer server side that keeps track when the last packet from a client was recieved. If that timer exceeds a set time then disconnect the client as they are now longer ''live''. The client will have to re-log in to continue.
The client always sends a packet to the server and the server responds. Rarely will it be the other way round.
Keep a timer server side that keeps track when the last packet from a client was recieved. If that timer exceeds a set time then disconnect the client as they are now longer ''live''. The client will have to re-log in to continue.
D.V.Carpe Diem
quote:
Original post by IStrikerI
and how do i check if a client has disconnected? not in all cases he sends a disconnection request (eg computer crashed).
If you don''t receive any information from client after a particular period of time then assume the client is ''dead'' and clean them up on the server. Can also make your client send out a ''heart beat'' to the server once every minute ( or whatever time ) to let the server know that the client is still alive.
-------
Andrew
PlaneShift - A MMORPG in development.
thx, ok i use both. i already did it just after my post, because it came into my head while writing the post.
i think i dont need a timeout-function. recv with tcp returns 0 if the connection has been gracefully closed otherwise SOCKET_ERROR (client crashed or just closed the app without disconnecting). or am i wrong? i checked it a couple of weeks ago, i just closed the client app and the recv function on the server returned SOCKET_ERROR for the socket of this client.
@acraig
does PlaneShift mean, that you use DynamicPlaneShifting for collision detection?
[edited by - IStrikerI on October 14, 2003 4:28:07 PM]
i think i dont need a timeout-function. recv with tcp returns 0 if the connection has been gracefully closed otherwise SOCKET_ERROR (client crashed or just closed the app without disconnecting). or am i wrong? i checked it a couple of weeks ago, i just closed the client app and the recv function on the server returned SOCKET_ERROR for the socket of this client.
@acraig
does PlaneShift mean, that you use DynamicPlaneShifting for collision detection?
[edited by - IStrikerI on October 14, 2003 4:28:07 PM]
Unless you are writing a multiplayer game (as apposed to a Massively Multiplayer game), you don''t want to leave sockets open 24/7. Not only that you don''t want the server to initiate the connection with the client.
Let the client make contact, the server has better things to do than determine if the client is still active by ''pinging'' or what ever other means.
D.V.
Carpe Diem
Let the client make contact, the server has better things to do than determine if the client is still active by ''pinging'' or what ever other means.
D.V.
Carpe Diem
D.V.Carpe Diem
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement