sockets - Python OSC, Query / Close active thread -
i'm using relatively simple python execution, using osc modules, in order 'send' code, application other.
import osc import threading #------osc server-------------------------------------# receive_address = '127.0.0.1', 9002 # osc server. there 3 different types of server. s = osc.threadingoscserver(receive_address) # define message-handler function server call. def printing_handler(addr, tags, stuff, source): if addr=='/coordinates': print "test", stuff s.addmsghandler("/coordinates", printing_handler) def main(): # start oscserver print "starting oscserver" st = threading.thread(target=s.serve_forever) st.start() main()
runned once, work fine, listen on port 9002.
but, runned twice, return error:
socket.error: [errno 10048] 1 usage of each socket address (protocol/network address/port) permitted
my goal to:
- be able query on active thread's port
- close them
i've tried following...
import socket s = socket.socket(socket.af_inet, socket.sock_stream) result = s.connect_ex(('127.0.0.1', 900socket2)) print 'result: ', result s.close()
but giving me unsuccessful result. (returns 10061 both active , unactive port's thread)
python » documentation socketserver.baseserver:
shutdown()
tell serve_forever() loop stop , wait until does.
server_close()
clean server. may overridden.
Comments
Post a Comment