Private Sub AxWinsock1_DataArrival(ByVal sender As Object, ByVal e As AxMSWinsockLib.DMSWinsockControlEvents_DataArrivalEvent) Handles AxWinsock1.DataArrival Dim str As String = "" AxWinsock1.GetData(str) TextBox2.Text = TextBox2.Text & str & vbNewLine ListBox1.Items.Add(str) 'send message to Client
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click AxWinsock1.Listen() End Sub End Class
เครื่อง client
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click AxWinsock2.RemoteHost = "192.168.0.1" AxWinsock2.RemotePort = 6543 AxWinsock2.SendData(TextBox2.Text) TextBox2.Text = "" TextBox2.Focus() End Sub
Private Sub AxWinsock1_DataArrival(ByVal sender As Object, ByVal e As AxMSWinsockLib.DMSWinsockControlEvents_DataArrivalEvent) Handles AxWinsock2.DataArrival Dim str As String = "" AxWinsock2.GetData(str) TextBox1.Text = str & vbNewLine
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load