Information Technology Reference
In-Depth Information
End Sub
Private Sub tcpClient_DataArrival (ByVal bytesTotal As Long)
Dim str As String
myTCPClient.GetData str
ShowText.Text = str
End Sub
Figure 24.14 Client form
The program, when it is run, will act as a client and a server. Any text typed in the
SendTxtData TextBox will be sent to the ShowText TextBox on the other form.
24.10.3 Multiple connections
In Visual Basic, it is also possible to create multiple connections to a server. This is done by
creating multiple occurrences of the server object. A new one is created every time there is a
new connection (with the Connection_Request event). Each new server accepts the incoming
connection. The following code, which has a WinSock control on a form called multServer,
is given below.
Private ConnectNo As Long
Private Sub Form_Load()
ConnectNo = 0
multServer(0).LocalPort = 1001
multServer(0).Listen
End Sub
Private Sub multServer_ConnectionRequest _
Search WWH ::




Custom Search