Hi all!
I have an app using pygtk and in a separate thread I have a server responding to specific calls on port 1120. Everything works fine except one thing: When I exit my app, everything shuts own properly but if I start up my app again right after (and the following couple of minutes) I get the error: (98, 'Address already busy') on code line 1:

socket.bind(('', 1120))
server.listen(5)

To me it seems as if the port is not released properly at shutdown, am I right?
How do I make port release at shutdown?
I have done as you should in pygtk:

import gobject
gobject.threads_init()

all my client calls are also closed with:

socket.close()

and at the server end at closedown:

socket.close()

and in my main thread:

self.__server.join()
gtk.main_quit()

I have checked that my thread self.__server.isAlive() is false before gtk quit.
What am I missing?
Please help!

Many thanks
Marcux

Take a look at SO_REUSEADDR socket option. For a record, I didn't recommend using it.

Thank you nezachem!
That solved my problem!
Thanks!
Marcux

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.