查看: 3  |  回复: 0
  VB6 Winsock的Bind的4种绑定法,不给具体例子了,直接给部分代码
楼主
发表于 今天 15:20
With Winsock1
    If .State <> sckClosed Then .Close

    '绑定
    If lngLocalPort = 0 And strLocalIP = "" Then .Bind
    If lngLocalPort = 0 And strLocalIP <> "" Then .Bind 0, strLocalIP    '效果同不定义--> .Bind , strLocalIP

    If lngLocalPort <> 0 And strLocalIP = "" Then .Bind lngLocalPort
    If lngLocalPort <> 0 And strLocalIP <> "" Then .Bind lngLocalPort, strLocalIP
End With

测试下来

.Bind 0, strLocalIP
就是
.Bind , strLocalIP

端口0会让Winsock1自动找空闲端口,如果strLocalIP给的IP,比如"192.168.1.8"不是当前计算机可用IP会报错。

您需要登录后才可以回帖 登录 | 立即注册
【本版规则】请勿发表违反国家法律的内容,否则会被冻结账号和删贴。
用户名: 立即注册
密码:
2020-2025 MaNongKu.com