What VB6 socket component can reuse bound ports?
I'm updating legacy code written in VB6 using Winsock controls. Essentially, I'm trying to connect 4 computers across a local network such that the computers can share files between each other when needed. Originally, once a connection was established, they held onto them indefinitely. These would error after 12-24 hours, however, and couldn't be reestablished.
To make matters worse, the entire network is wrapped in tight security, and we only have a set number of ports to work with (their firewall blocks all other ports.) I suspect the network security is responsible for closing connections that have been inactive for too long, and are the cause of our instability (our tests here ran indefinitely and reestablished themselves if we rebooted any of the computers.)
开发者_JAVA技巧My thought is to only establish connections on demand, when a file needs to be sent, to avoid this possibility. The problem I run into is that you cannot connect through the same port for four minutes. So no more than one file can be sent in a four minute window (unless you have all the files at once, but they're generated at different times.) Using three ports allow three files to be sent at once (one to each peer) but then I'm locked down for four more minutes. I could keep adding ports, but this seems inelegant at best, and will not be allowed by their IT department, at worst.
Any ideas? I can't find any other socket controls for VB6 that allow reusable bound ports.
The "four minute delay" is per connection, where a TCP connection is the 4-tuple consisting of the local IP, local port #, remote IP, and remote port #.
This is normally only an issue for a client that tries to establish a connection to a server using the same localport value repeatedly. For the Winsock control you might try simply setting LocalPort to 0 before attempting each new connection to the remote server.
Another way that might avoid connections sitting in TIME-WAIT is to be sure to actively CLOSE the connection when the CLOSE event is raised by the other end.
Using 3 ports to send 3 files seems a little odd. I wouldn't think this gains you any performance over sending the 3 files one after another using a single connection.
精彩评论