Jump to content
Sign in to follow this  

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

Share this post

Link to post
Share on other sites


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)

TCPSend($_sock, 'CLOSE')
TCPCloseSocket($_sock)oÝ÷ Ù«­¢+Øí
AIØ ÀÌØí}ͽ¬°Ô¤)%ÀÌØí}ÉØôÌäí
±½Í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.


OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control


Share this post

Link to post
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

Share this post

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