Jump to content
  • Advertisement
Sign in to follow this  
junker10

tcp kick play

This topic is 2883 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

Advertisement
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
No, I won't give you code. This is trivial to research, type "close socket" into Google and you'll get more examples than you could possibly need.

If you want code, you'll need to demonstrate What you have tried.

Share this post


Link to post
Share on other sites
Quote:
Original post by junker10
can i kick by ip and can i get code plazz and ty
Yes. Find the socket(s) with that IP address as their endpoint and close them.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!