Skip to content

Instantly share code, notes, and snippets.

@wcypierre
Created July 13, 2013 07:49
Show Gist options
  • Save wcypierre/5989871 to your computer and use it in GitHub Desktop.
Save wcypierre/5989871 to your computer and use it in GitHub Desktop.
[Posix UDP] What to consider when coding for the multithreaded udp server with thread pool
1. The socket's file descriptor must be global(if you wanted to share the socket)
2. You must pass the sizeof the destination length(sizeof(client_addr)) into the thread in pthread_create as if you do not then you won't get a correct result as the client_addr is a pointer to sockaddr_in instead of sockaddr_in, so the return value of sizeof() won't be the one that we wanted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment