Listener not Listening...

Illusion

Well-known member
Joined
Aug 7, 2003
Messages
105
Location
Uk
Hi,

I was messing about the .Net socket code yesterday, hoping to make some use of it, (simple chat program, you know the sort) I tried to run the program which worked fine, but the listener doesnt open a port so doesnt listen...
maybe I am missing something, but either way its not working :(

Any ideas?

a snippet from the MS Socket samples (which can be found on their website).
Code:
Private Sub DoListen()
        Try
            Dim port As Integer = "5000"
            
            mobjListener = New TcpListener(port)

            mobjListener.Start()
            Do
                Dim x As New Client(mobjListener.AcceptSocket)
                Dim x As New Client(mobjListener.AcceptTcpClient)

                AddHandler x.Connected, AddressOf OnConnected
                AddHandler x.Disconnected, AddressOf OnDisconnected
                AddHandler x.CharsReceived, AddressOf OnCharsReceived
                AddHandler x.LineReceived, AddressOf OnLineReceived
                mcolClients.Add(x.ID, x)
                Dim params() As Object = {"New connection"}
                Me.Invoke(New StatusInvoker(AddressOf Me.UpdateStatus), params)
            Loop Until False
        Catch
        End Try
    End Sub

Thanks
Daniel.
 
If option strict is enabled, that should cause a compiler error. If option strict is off, that should convert fine. I recommend turning option strict on, however, to catch other similar potentially harmful errors.

I dont understand that code. I also dont know sockets, but it looks like that code will just continually create new Client objects, adding handlers, and adding them to a collection in an infinite loop. Not something you normally want to do... Did you copy and paste that exactly?
 
Hi,

thanks for replying,
I actually forgot about this post I made, sorry abotu that.
The code works fine, it was the computer I was using it on that didnt work, I have no idea why.
Its all made by microsoft as a sample to Sockets if anyone wants to use it.

Thanks
Illusion.
 
Back
Top