wqweto / VbAsyncSocket

Sockets with pure VB6 impl of TLS encryption
MIT License
164 stars 31 forks source link

Samples for cAsyncSocket.cls #18

Open dragokas opened 3 years ago

dragokas commented 3 years ago

Hi, Can I ask you please to help me with ports leaking?

I prepared and attached another one simple samples (based on your chat samples and my previous forms https://github.com/wqweto/VbAsyncSocket/issues/7 ), you may want (or may not) include them as samples in your project in the future.

This time without controls at all. I moved the operational part to separate classes to minimize code size in the main form module.

There are 3 projects: 1) Client 2) Server 3) Client-Server (same as 1 + 2, merged together).

If you try to send several packets (using project # 3, or bunch of # 1 + # 2), you will see, that ports are get occupied with status "Time Wait", which is automatically free by system after ~ 120 sec. However, those should have been instantly free with Socket.Close_ method. Why it doesn't want to?

Thanks a lot for your help.

leak

Attachment: https://dragokas.com/temp/Socket-samples.zip (can't attach for some reason).

wqweto commented 3 years ago

Remaining TIME_WAIT is normal. Check out this console session

C:\Users\wqw>nslookup rusradio.ru 8.8.8.8
Server:  dns.google
Address:  8.8.8.8

Non-authoritative answer:
Name:    rusradio.ru
Address:  31.184.225.242

C:\Users\wqw>netstat -ano | findstr -i 31.184.225.242

C:\Users\wqw>curl http://rusradio.ru -o nul
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   194  100   194    0     0    194      0  0:00:01 --:--:--  0:00:01  1243

C:\Users\wqw>netstat -ano | findstr -i 31.184.225.242
  TCP    172.17.17.104:31737    31.184.225.242:80      TIME_WAIT       0

C:\Users\wqw>netstat -ano | findstr -i 31.184.225.242
  TCP    172.17.17.104:31737    31.184.225.242:80      TIME_WAIT       0

C:\Users\wqw>netstat -ano | findstr -i 31.184.225.242
  TCP    172.17.17.104:31737    31.184.225.242:80      TIME_WAIT       0

C:\Users\wqw>netstat -ano | findstr -i 31.184.225.242
  TCP    172.17.17.104:31737    31.184.225.242:80      TIME_WAIT       0

C:\Users\wqw>netstat -ano | findstr -i 31.184.225.242

C:\Users\wqw>

On Win10 the TIME_WAIT state past closing the socket remains for ~30 seconds.