Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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 doesn't open a port so doesn't 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).

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.

  • 1 month later...
Posted
Maybe it is because port is dimed as an Integer, and you are saying = "5000" try taking out the quotes.

~Nate�

___________________________________________

Please use the [vb]/[cs] tags on posted code.

Please post solutions you find somewhere else.

Follow me on Twitter here.

  • Leaders
Posted

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 don't understand that code. I also don't 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?

[sIGPIC]e[/sIGPIC]
Posted

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 didn't work, I have no idea why.

It's all made by microsoft as a sample to Sockets if anyone wants to use it.

 

Thanks

Illusion.

  • 3 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...