Article ID: 152057
Article Last Modified on 7/15/2004
Private gSockInstance
Private Sub Form_Load()
gSockInstance = 0
TCP1(0).LocalPort = 1007
TCP1(0).Listen
End Sub
Private Sub TCP1_ConnectionRequest(Index As Integer, _
ByVal requestID As Long)
gSockInstance = gSockInstance + 1
Load TCP1(gSockInstance)
TCP1(gSockInstance).Accept requestID
End Sub
Private Sub TCP1_DataArrival(Index As Integer, ByVal bytesTotal _
As Long)
Dim vta
TCP1(Index).GetData vta, vbString
MsgBox vta, 0, "Server"
End Sub
Private Sub Command1_Click()
With TCP1
.RemoteHost = "machine name you specify"
.RemotePort = 1007
.Connect
End With
End Sub
Private Sub Command2_Click()
TCP1.SendData "This is how we begin"
End Sub
Private Sub TCP1_Connect()
If (TCP1.State = sckConnected) Then
MsgBox "connection successful"
Else
MsgBox "connection failed"
End If
End Sub
For demonstration purposes of this article, the client and server
execute on the same machine. TCP1.RemoteHost is specified as the machine
where the server is running. However, a simple change to the RemoteHost
property will allow you to connect to any machine with a Point-to-Point
connection.
Keywords: kbwinsock kbapi kbnetwork KB152057