Results 1 to 13 of 13

Thread: [Resolved] Problem with code please help (System.Net.Sockets) Related

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2004
    Posts
    37

    [Resolved] Problem with code please help (System.Net.Sockets) Related

    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:
    1. Private Sub cmdListen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdListen.Click
    2.         Dim ipadd As IPAddress = IPAddress.Parse("192.168.1.100")
    3.         Dim port As String = "9909"
    4.         Dim bytes(1024) As [Byte]
    5.         Dim data As [String] = Nothing
    6.  
    7.         Dim Listen As New TcpListener(ipadd, port)
    8.         Listen.Start()
    9.  
    10.         Dim client As TcpClient = Listen.AcceptTcpClient()
    11.  
    12.  
    13.         data = Nothing
    14.  
    15.  
    16.         Dim stream As NetworkStream = client.GetStream()
    17.  
    18.         Dim i As Int32
    19.  
    20.  
    21.         i = stream.Read(bytes, 0, bytes.Length)
    22.  
    23.         data = System.Text.Encoding.ASCII.GetString(bytes, 0, i)
    24.         MsgBox([String].Format("Received: {0}", data))
    25.  
    26.         i = stream.Read(bytes, 0, bytes.Length)
    27.         cmdListen.Enabled = False
    28.  
    29.     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
    Last edited by dsc_chris; Jul 26th, 2004 at 03:04 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width