Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Starting project… Need help xP


lexkymbeth
 Share

Recommended Posts

```
socket.close

```
Keep in mind: this closes the socket client side. The server has to send a message to the client that it needs to close. The server should also refuse messages from kicked people until theny reconnect.

Also, I'm not sure if your chat is integrated into Origins or if it is a seperate entity. If it is integrated into Origins, you'll have to clean up Origins too.
Link to comment
Share on other sites

@Soul:

> ```
> socket.close
>
> ```
> Keep in mind: this closes the socket client side. The server has to send a message to the client that it needs to close. The server should also refuse messages from kicked people until theny reconnect.
>
> Also, I'm not sure if your chat is integrated into Origins or if it is a seperate entity. If it is integrated into Origins, you'll have to clean up Origins too.

its not, thanks tho xD i thought no one would tell. so when i send a packet to the client
```
socket.close
```will close just that client or them all…?
Link to comment
Share on other sites

@lexkymbeth:

> its not, thanks tho xD i thought no one would tell. so when i send a packet to the client
> ```
> socket.close
> ```will close just that client or them all…?

Nope. You'll have to do two things:

One, tell the client it has to go (send a packet to it, then have the client check if the packet content matches the close signal).
Two, tell the server to ignore anything the client sends until it reconnects (otherwise, people could filter out the close signal).
Link to comment
Share on other sites

@Scootaloo:

> Actually, if you close the socket on the server side the client side socket should raise an error saying it was closed.
>
> That's how TCP works.

But nothing stops the user from reconnecting quickly. (I interpreted "kick" as ban them for like a minute or so, although in hindsight I'm not sure if that's what the OP wanted.)
Link to comment
Share on other sites

@Scootaloo:

> Actually, if you close the socket on the server side the client side socket should raise an error saying it was closed.
>
> That's how TCP works.

"If the socket is connection oriented and the remote side has shut down the connection gracefully, and all data has been received, a recv will complete immediately with zero bytes received. If the connection has been reset, a recv will fail with the error WSAECONNRESET." - MSDN.
i.e. unless you have to tell something important before closing the connection, you shouldn't bother being polite to your client, since TCP already is.

@Soul:

> But nothing stops the user from reconnecting quickly. (I interpreted "kick" as ban them for like a minute or so, although in hindsight I'm not sure if that's what the OP wanted.)

Neither will what you just described. To do that you would have to store the IP-address in a list, with a timestamp in the future of when the entry becomes invalid, and simply refuse any connections that are made coming from that IP-address. Or, simply block account authentication through the same way.

Yours faithfully,
  Stephan.
Link to comment
Share on other sites

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
 Share

×
×
  • Create New...