代码如下:
Private Sub StartListen()
intport = Integer.Parse(TextBox1.Text)
Try
mysocket = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
mysocket.Bind(New IPEndPoint(IPAddress.Parse("127.0.0.1"), intport))
mysocket.Listen(10)
TextBox2.Text = "等待Socket客户端连机中......." + vbCrLf
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'启动监听按钮的代码
Dim mythread As New Thread(New ThreadStart(AddressOf StartListen))
mythread.Start()
End Sub
划红色的部分,不太理解,<1>线程在这里有什么作用?直接调用过程不可以吗? <2>Addressof是什么东东哦,构造函数里面的参数AddressOf StartListen是什么东东?望大家帮忙,谢谢