Demo entry 6682941

main

   

Submitted by anonymous on Dec 11, 2017 at 13:28
Language: Python. Code size: 543 Bytes.

def main():
    pid = str(os.getpid())
    pidfile = "/tmp/makolli_centor.pid"

    if os.path.isfile(pidfile):
	print "%s already exists, exiting" % pidfile
	sys.exit()
    file(pidfile, 'w').write(pid)
    try:
    	HOST = ""
    	PORT = 50505
    	s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    	s.bind((HOST, PORT))

    	while True:
    	    socket_thread = threading.Thread(target=set_socket, args=(s,))
	    socket_thread.start()
	    socket_thread.join()

    	s.close()
    finally:
	os.unlink(pidfile)

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).