multithreading - Re-Entrant or Thread Safe -


I have applied this code to hailing many customers. I doubt it. Is this function re-entering function?

  zero * connection_handler (zero * socket_desc) {// socket descriptor int sock = * (int *) socket_desc; Int read_size; Four * messages, client_meas [2000]; // Send some messages in the client message = "Hello! I'm your connection handler \ n"; Write (sock, message, strangel (message)); Message = "Now type something and I'll repeat what you type \ n"; Write (sock, message, strangel (message)); // When sending a message from the client ((read_size = recv (sock, client_message, 2000, 0)); {// send the message back to write client (sock, client_meme, strangel (client_message)); } If (read_size == 0) {puts ("client disconnected"); Fflush (stdout); } And if (read_size == -1) {false ("recv failed"); } // Free Socket Indicator (socket_desc); Return 0; }  

If it manages multiple clients, it means how is it synchronized?

I call this function in main function using pthread_create.

Thank you.


Comments

Popular posts from this blog

HTML/CSS - Automatically set height width from background image? -

php - Mysql Show Process - Sleep Commands and what to do -

c - What is the address of buf (the local variable in the main function)? -