

Private Sub cmdListen_Click() 'Setup the local port to connect to. You can put any port number. Winsock.LocalPort = 4545 'Listen for incoming connections Winsock.Listen End Sub
Private Sub Winsock_ConnectionRequest(ByVal requestID As Long) 'Close a connection incase a previous one was opened. Winsock.Close 'Accept the request Winsock.Accept requestID 'If connection is made, Tell user If Winsock.State = sckConnected Then lstShow.AddItem "Connection Made" Else msgbox "No Connection Made",,"Error" End If End Sub
Private Sub cmdConnect_Click() Dim IP as Integer 'Get the Computer to connect to IP = txtConnect.text 'Close Previous Connection Winsock.Close 'Connect to Computer Using the IP and Port (Port must be the same as the Listening Winsock) Winsock.Connect IP, 4545 'If connection is made, Tell user If Winsock.State = sckConnected Then lstShow.AddItem "Connection Made" Else msgbox "No Connection Made",,"Error" End If End Sub
Private Sub cmdSend_Click() Dim Data as String 'Get the data to send Data = txtSend.text 'Append your hostname so they know who sent it Data = Winsock.LocalHost & ": " & Data 'Send your data Winsock.SendData Data 'Display the Data for yourself lstShow.AddItem Data End Sub
Private Sub Winsock_DataArrival(ByVal bytesTotal As Long) Dim Data as String 'Get the data sent to the winsock and put it in the Variable "Data" Winsock.GetData Data 'Display the data lstShow.AddItem Data End Sub