Sign in to follow this  

tcp kick play

This topic is 2665 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

You kick them by closing the connection, as Anddos mentioned. If you are looking to kick them in such a way that they cannot return, you might need some kind of IP-blacklist in your server code when a connection is started.

Share this post


Link to post
Share on other sites
A user is a "char"? Is a char an index into some array? But then you can't call close() on it, because close() takes a file descriptor, which is an int(). (I'm assuming Linux here).

It sounds like you want to do two things here:

1) given a currently connected user, disconnect that user from the current game session.

2) once disconnected, you also want to add that user's IP address to a ban list, so it cannot re-connect.

To do 1), simply find the user and call close() (or closersocket(), if on Windows) on the socket, the same as you would if the user issued the "quit" command.

To do 2), before you close the session, you need to call getpeername() to extract the IP address of the user. You then put that IP address in some list/map/hash table of banned IP addresses. When you get a new socket from a call to accept(), check the IP address of that socket with the list of banned IP addresses. If it's a match, immediately close() the socket instead of establishing a connection object for the connected user.

Share this post


Link to post
Share on other sites

This topic is 2665 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this