server如何接收
client的代码如下
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Sub client_Connect()
MsgBox "连接成功"
End Sub
Private Sub client_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
MsgBox "连接错误,请检察网络设置,或服务器没有启动,请关闭重试"
client.Close
End Sub
Private Sub Command1_Click()
client.SendData strString
End Sub
Private Sub Form_Load()
client.RemoteHost = "192.168.1.251"
client.RemotePort = 8612
client.Connect
Dim strString As String
strString = String(255, Chr$(0))
GetComputerName strString, 255
strString = Left$(strString, InStr(1, strString, Chr$(0)) - 1)
End Sub
server的代码如下
Private Sub Form_Load()
server.LocalPort = 8612
server.Bind
server.Listen
End Sub
Private Sub server_Close()
server.Close
server.Listen
End Sub
Private Sub server_DataArrival(ByVal bytesTotal As Long)
Dim strstring As String
server.GetData strstring, vbString
Text1.Text = strstring + Chr$(13) + Chr$(10) + Text1.Text
End Sub
[此贴子已经被作者于2007-8-4 10:09:13编辑过]