Jump to content

TCP Connect/Disconnect?


Recommended Posts

Okay, this is kind of a general question, but also relates to au3. So, here is my question:

Assume client and server are connected.

Now, I want to disconnect the client-side without exiting the program or using tcpshutdown.

Should I go about doing this client-side, with TCPloseSocket? Or, on the server-side, with the same command?

I've seen client-side disconnect will result in a Time_wait state. (not good if i have alot of these on my server)

If i'm going to do it via server, then there would have to be an initiation packet to tell the server to disconnect me...

I'm creating a registration function. But, it requires the client to disconnect after registering.

I will also be using this function later on, after they connect, they can click "disconnect". (send a packet to disconnect?)

after disconnection, they will then be able to reconnect.

I don't know if you've ever connected to battle.net, but it's the exact same thing that i'm attempting to do. (but in my own protocol)

Should i go about disconnecting client-side, or server-side? (and if client-side, how should i go about this?)

If something isn't clear to you, please let me know.

(i'm not the best at explaining things. :P)

tolle indicium

Link to comment
Share on other sites

@Glyph

After the function "TCPCloseSocket", the server or the client won't be able to send or receive something from this socket in the way that you will get an error...

But there is only this function for "disconnect" client and the server.

Dont forget, its better to close any openned socket before use "TCPShutdown" function :unsure:

you can tell to the client to close the connection with this way :

$_sock is the openned socket (with TCPAccept or TCPConnect)

;Server
TCPSend($_sock, 'CLOSE')
TCPCloseSocket($_sock)oÝ÷ Ù«­¢+Øí
±¥¹Ð(ÀÌØí}ÉØôQ
AIØ ÀÌØí}ͽ¬°Ô¤)%ÀÌØí}ÉØôÌäí
1=MÌäìQ¡¸Q
A
±½ÍM½­Ð ÀÌØí}ͽ¬

You can use a looping instead of using the 'If' statement, its better for receive any information without miss it :P

Hope that help !

Cheers, FireFox.

Link to comment
Share on other sites

Thanks, but my issue has no "error".

The TCPCloseSocket returns a state of time_wait, (in command prompt [netstat -n -b]) when closed client side.

Server side closing works fine, but is this the proper way to close a socket?

that's my question in a nut-shell.

tolle indicium

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...