哪些 VB6 套接字组件可以重用绑定端口?
我正在使用 Winsock 控件更新用 VB6 编写的遗留代码。本质上,我试图通过本地网络连接 4 台计算机,以便计算机可以在需要时在彼此之间共享文件。原本,一旦建立了联系,他们就会无限期地保留下去。然而,这些将在 12-24 小时后出错,并且无法重新建立。
更糟糕的是,整个网络都处于严格的安全保护之下,我们只有一定数量的端口可以使用(他们的防火墙阻止所有其他端口。)我怀疑网络安全负责关闭已经不活动太久的连接,这是我们不稳定的原因(我们这里的测试无限期地运行,如果我们重新启动任何计算机,它们就会重新建立。)
我的想法是仅当文件需要时才按需建立连接发送,以避免这种可能性。我遇到的问题是您无法通过同一端口连接四分钟。因此,在四分钟的窗口内不能发送超过一个文件(除非您一次拥有所有文件,但它们是在不同时间生成的。)使用三个端口允许一次发送三个文件(每个对等点一个) )但随后我又被锁定了四分钟。我可以继续添加端口,但这在最好的情况下看起来很不优雅,在最坏的情况下也不会被他们的 IT 部门允许。
有什么想法吗?我找不到任何其他允许可重用绑定端口的 VB6 套接字控件。
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.)
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“四分钟延迟”是针对每个连接的,其中 TCP 连接是由本地 IP、本地端口号、远程 IP 和远程端口号组成的 4 元组。
这通常只是尝试重复使用相同本地端口值与服务器建立连接的客户端的问题。对于 Winsock 控件,您可以尝试在尝试与远程服务器的每个新连接之前简单地将 LocalPort 设置为 0。
另一种可能避免连接处于 TIME-WAIT 状态的方法是确保在另一端引发 CLOSE 事件时主动关闭连接。
使用 3 个端口发送 3 个文件似乎有点奇怪。我认为这不会比使用单个连接依次发送 3 个文件带来任何性能提升。
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.