title: C socket API is thread safe?
body: <p>I'm using both Linux and Win32 socket APIs. In my program, multiple threads share a socket handle. In particular, multiple threads call <code>send</code> with the shared socket handle (i.e., the same port). In this case, do I have to put a lock for thread safety? I was unable to find the answer. I may do a test, but want to hear your experiences.</p>
  
  <p><strong>EDIT</strong>: I know that such sending data via socket isn't atomic operation at all. Definitely we have to use a mutex for thread safety. However, I was wondering whether the system API could have their own internal lock. If so, we can omit putting our own lock.</p>
  
  <p>This question may be applicable to <code>fprintf</code> function as well. I'm wondering such system APIs would have their own locks. In my experience, calling <code>fprintf</code> from multiple threads didn't kill my program although there was races on a file or stdout (i.e., inconsistent or unpredictable outputs, but the program was not crashed), which implied <code>fprintf</code> had a lock to protect their internal data structure.</p>