Information Technology Reference
In-Depth Information
Add the code given below to the form.
6
Private Sub Form_Load()
' Set the local port to 1001 and listen for a connection
myTCPServer.LocalPort = 1001
myTCPServer.Listen
myClient.Show
End Sub
Private Sub myTCPServer_ConnectionRequest (ByVal requestID As Long)
' Check state of socket, if it is not closed then close it.
If myTCPServer.State <> sckClosed Then myTCPServer.Close
' Accept the request with the requestID parameter.
myTCPServer.Accept requestID
End Sub
Private Sub SendTxtData_Change()
' SendTextData contains the data to be sent.
' This data is setn using the SendData method
myTCPServer.SendData = SendTextData.Text
End Sub
Private Sub myTCPServer_DataArrival (ByVal bytesTotal As Long)
' Read incoming data into the str variable,
' then display it to ShowText
Dim str As String
myTCPServer.GetData str
ShowText.Text = str
End Sub
Figure 24.12 Server set-ups
Figure 24.13 shows the server setup.
Search WWH ::




Custom Search