Illusion Posted April 28, 2005 Posted April 28, 2005 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. Quote
Nate Bross Posted June 3, 2005 Posted June 3, 2005 Maybe it is because port is dimed as an Integer, and you are saying = "5000" try taking out the quotes. Quote ~Nate� ___________________________________________ Please use the [vb]/[cs] tags on posted code. Please post solutions you find somewhere else. Follow me on Twitter here.
Leaders snarfblam Posted June 3, 2005 Leaders Posted June 3, 2005 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? Quote [sIGPIC]e[/sIGPIC]
Illusion Posted June 5, 2005 Author Posted June 5, 2005 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. Quote
Gooley Posted September 5, 2005 Posted September 5, 2005 i thought you didn't need to loop it... Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.