I am not certain what you really want to be the server functionality, but based on your example, what you have is a server that can accept and process one client at a time. What I would suggest is not rebinding the server every time after every connection. It is not necessary.
Bind the socket once, then go into a loop waiting for clients:
def run(self):
server_socket = socket.socket()
host = socket.gethostname()
port = 12345
server_socket.bind((host, port))
server_socket.listen(5)
while True:
# this will block until a client tries to connect
client_socket, address = server_socket.accept()
print 'Got connection from', address
logging.info(address)
# this will block until data is received from client
data = client_socket.recv(1024)
logging.info(data)
What will happen here is the server will accept a client and then block while waiting for the client to send something. Then it will loop again waiting for a new client. You may even want to close that socket if it is a one-off connection and you are done handling it.
If you want to be able to handle multiple clients at the same time, then you would do the loop in your main thread, and then pass each new connection off to a worker thread to handle the communication. This will free up the main thread to continue looping and waiting for new clients to connect.
This can be achieved by either starting a brand new thread for each client and passing the socket, or, using a Queue shared between a fixed pool of running threads. Each thread would be waiting to pull an item from the queue, and then go into a communication loop on the socket item. When it is done, it goes back to waiting on the queue.
Pseudo-code might look something like this:
socket_queue = Queue()
...
def main_server_thread():
while True:
# this will block until a client tries to connect
client_socket, address = server_socket.accept()
print 'Got connection from', address
logging.info(address)
# this will finish right away and loop again
socket_queue.put(client_socket)
...
def client_worker_thread():
while True:
sock = socket_queue.get()
while sock is still connected:
data = sock.recv(1024)
logging.info(data)