I've started with socket programming and follow question arose:
If, in the server, I get a client/socket connection with function:
Then, is it a problem if I access later on this client_sockfd from two separate threads? Can I close() it from any of them?
I'm thinking of creating a thread to read() the socket and another separate one to write(), since I have asynchronous communication in both ways. Do I need to dup() client_sockfd, or just using the same absolute number for the separate threaded read() and write() is fine?
If, in the server, I get a client/socket connection with function:
Code:
client_sockfd = accept( server_sockfd, (struct sockaddr *) &client_address, &client_len );
I'm thinking of creating a thread to read() the socket and another separate one to write(), since I have asynchronous communication in both ways. Do I need to dup() client_sockfd, or just using the same absolute number for the separate threaded read() and write() is fine?
Comment