Ok, I have the following code working except my form locks up until someone connects, then after they connect it locks up until data is sent once data is received and a msg box pops up the form locks up again... Can someone tell me what I am doing wrong? This does exactly what I need it to do but what I dont need it to do is lock up the form.
VB Code:
Private Sub cmdListen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdListen.Click Dim ipadd As IPAddress = IPAddress.Parse("192.168.1.100") Dim port As String = "9909" Dim bytes(1024) As [Byte] Dim data As [String] = Nothing Dim Listen As New TcpListener(ipadd, port) Listen.Start() Dim client As TcpClient = Listen.AcceptTcpClient() data = Nothing Dim stream As NetworkStream = client.GetStream() Dim i As Int32 i = stream.Read(bytes, 0, bytes.Length) data = System.Text.Encoding.ASCII.GetString(bytes, 0, i) MsgBox([String].Format("Received: {0}", data)) i = stream.Read(bytes, 0, bytes.Length) cmdListen.Enabled = False End Sub
Basically the code is setup to listen on an IP/Port. When someone connects it will wait for that persons input then display a msg box when they type something. I am wanting to grab what they type and depending on what they type do a specific thing. I already know how to do this as long as the form doesnt lock up!
Thanks for any help.
P.S. Hope I am not confusing![]()




Reply With Quote