你好,可以参考以下代码:
服务器:
private sub form_load()
winsock1.localport = "1234"
winsock1.listen
end sub
private sub winsock1_connectionrequestA(byval requestid as long)
if winsock1.state <> sckclosed then
winsock1.close
end if
end sub
private sub winsock1_dataarrival(byval bytestotal as long)
dim str as string
winsock1.getdata str
select case str
case "关闭"
........
case "重启"
.........
end select
end sub
客户:
private sub winsock1_connect()
winsock1.senddata "指令"
end sub
private sub command1_click()
on err resume next
winsock1.remoteport=1234
winsock1.remotehost="ip"
winsock1.connect
end sub