由于是要用到vb6的控件,即MSWINSCK.OCX,所以如果运行错误,那么下载此附件vb6controls.reg注册- '服务端
- 'by wuditom100
- '有不足的地方欢迎改进
- Dim revdata
- set sock=WScript.createobject( "MSWinsock.Winsock" , "WSEvent_" )
- PORT=InputBox ("sever输入要打开的端口:","PORT","")
- sock.LocalPort =PORT
- sock.Listen
- Sub WSEvent_ConnectionRequest(requestID)
- sock.Close
- sock.Accept requestID
- End Sub
-
- Sub WSEvent_DataArrival(bytes)
- MyString= ""
- sock.GetData MyString
- revdata="cilent说:" & MyString
- MsgBox revdata
- End Sub
- While Not bClose
- data=InputBox("输入要发送的信息","server发送","")
- If data<>"" then
- sock.senddata data
- WScript.Sleep 1
- Else
- WScript.Quit
- End if
- Wend
复制代码 ---------------------------------- '客户段
- 'by wuditom100
- '有不足的地方欢迎改进
- Dim revdata
- set sock=WScript.createobject( "MSWinsock.Winsock" , "WSEvent_" )
- IP=InputBox("cilent输入连接的IP:","IP","")
- PORT=InputBox ("cilent输入连接的PORT:","PORT","")
- sock.connect IP , PORT
-
- Sub WSEvent_Connect()
- wscript.echo "连接成功!"
- end sub
- Sub WSEvent_ConnectionRequest(requestID)
- sock.Close
- sock.Accept requestID
- End Sub
-
- Sub WSEvent_DataArrival(bytes)
- MyString= ""
- sock.GetData MyString
- revdata="server说:"&MyString
- MsgBox revdata
- End Sub
- While Not bClose
- data=InputBox("输入要发送的信息","cilent发送","")
-
- If data<>"" Then
- sock.senddata data
- WScript.Sleep 1
- Else
- WScript.Quit
- End if
- Wend
复制代码
[ 本帖最后由 Batcher 于 2009-5-16 14:21 编辑 ] |