The party that initiated the closure of the connection is the one that ends in the state TIME_WAIT. read()return 0 should indicate that the server was the first to close the socket, so yes - this should mean that it TIME_WAITends on the server side, and the client goes through LAST_ACK.
At the end of the day you cannot escape the condition TIME_WAIT. Even if you manage to transfer it from the client to the server, you still cannot reuse this tuple (server host, server port, client host, client port)until TIME_WAITit ends (regardless of which side it is on).
Since the three parts of the tuple are fixed in your script ( server host, server port, client host), you really only have these options:
. " " ( OSX ). , , , , bind()/connect() , .
client host , IP- . bind() IP-, .
server host/server port, / IP- . (, ..).
, , : , , " ", , (, HTTP keep-alive).