Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click ip = Form2.TextBox1.Text port = Form2.TextBox2.Text
If connectstate = 0 Then socket1.Connect(iport) Else socket1.Shutdown(SocketShutdown.Both) socket1.Close() End If If socket1.Connected = True Then Label6.Text = "已连接" & " " & ip & ":" & port Button1.Text = "断开" connectstate = 1 Else Label6.Text = "未连接" Button1.Text = "连接" connectstate = 0 End If End Sub