Jump to content
  • Advertisement
Sign in to follow this  
Kryptus

Socket Problem

This topic is 4870 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've just started to make my own server client program in VB.NET with the following code in the server... Public Sub Listen() ServerThread = New Thread(AddressOf DoListen) ServerThread.Start() sblblMain.Text = "Listening for incoming connections..." End Sub ' Start listening for incoming connections Public Sub DoListen() Try ServerListener = New TcpListener(23678) ServerListener.Start() ' >>> SOME CODE <<< Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub The error message i get says "Only one usage of each socket address (protocol/network address/port) is normally permitted" and it doesn't reach the area called "some code". How do I correct this problem?

Share this post


Link to post
Share on other sites
Advertisement
i don't know VB but i've use bsd sockets on unix systems a little in c and c++. it looks like the port is already in use. i don't know about vb, but is it possible that the socket wasn't released from a previous run of your program?

Share this post


Link to post
Share on other sites
Thanks for that pointer. I've done a lot of testing and debugging and narrowed my problem down to two things. The First being that I did not close the socket properly, and the second being that my firewall would always interfere.

Share this post


Link to post
Share on other sites
i should have mentioned that with bsd sockets you can set the SO_REUSEADDR option. you can use this to reuse the port for your listen socket if the socket wasn't properly closed, like in the case of a crash.

Share this post


Link to post
Share on other sites
In a command window, type "netstat -aon". This will show you all the open sockets in the system as well as the id of the program (PID) that owns the them. Check the port you are trying to bind to and see if it's in the list. If it is you can the type "tasklist" to cross-reference the PID with the name of the exe.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!