regarding winsock close event
hi, i wish to enquire a bit information regarding winsock close event.
let say, if we created a tcp server which able to accept multiple connection on port 80.
let say, a client connected to port 8080, we create a new socket and direct the client to the new sock with random port.
Code:
Proto Local Address Foreign Address State
TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING
TCP 127.0.0.1:1728 127.0.0.1:8080 ESTABLISHED
TCP 127.0.0.1:8080 127.0.0.1:1728 ESTABLISHED
so we got something like above when we netstat. now let say, the client program was not written properly, it didn't close it socket after the application shutdown. so, let say if i terminate the client application now, what i got in netstat is like below.
Code:
Proto Local Address Foreign Address State
TCP 127.0.0.1:1728 127.0.0.1:8080 FIN_WAIT_2
TCP 127.0.0.1:8080 127.0.0.1:1728 CLOSE_WAIT
so, since most of the winsock tutorial site teach us to write server that create a new sock based on (when sckClosed socket was not found in current winsock control array) so, when a new client try to connect us, our server create a new socket for it.
now, my question is, does this mean, somebody could (i mean fill up our server winsock control array which is 65536 only using such technique?)
Re: regarding winsock close event
The CLOSE_WAIT state is perfectly normal. For more information about it, a good resource is the Winsock Programmer's FAQ:
http://tangentsoft.net/wskfaq/articl...gging-tcp.html
It would be good to read the whole page, but you can skip on down to the section that talks about TIME-WAIT for more insight into what's going on.
Re: regarding winsock close event
thanks mike for ur repond.
eventually, i have coded a client which try to create multiple sock connection :)
well, my server application seem quite slow when the connection reach about 400. (i am on a pentium 4 with 256 MB ram)
is this normal? i guess it is quite hard to hack the server to reach 65536 concurrent connection.
Re: regarding winsock close event
The total number of sockets that you can create on Windows NT/2K/XP depends on the amount of physical memory you have (socket handles are allocated from the non-paged pool). Depending on what platform you're using, you can probably get about 3000-5000 connections; however, to approach those numbers, you're looking at writing a multithreaded program in C/C++ and using overlapped I/O.