sockets - How to deal with getaddrinfo and thread-safety? -


i using getaddrinfo ipv6-related c-project. "man getaddrinfo" on computer (uname -a: 3.5.0-23) indicates "reentrant". guess not thread-safe.

in scenarios thread-safety required, how handle it? checked unp seems no concrete answer provided. lot.

getaddrinfo() indeed thread-safe. required rfc 3493 section 6.1:

functions getaddrinfo() , freeaddrinfo() must thread-safe.

on platforms, gethostbyname() thread-safe, on others nt. gethostbyname() not on platforms reentrant. if call gethostbyname() , call gethostbyname() again in same thread, data first call overwritten data second call. because gethostbyname() uses static buffer internally, why have copy data before calling gethostbyname() again. getaddrinfo() not suffer problem, allocates new addrinfo struct every time called.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -