Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

92
Views
File locking a socket?

Is it possible to lock a socket for a thread? For example using flock?

These locks are designed for files, but they take a generic file descriptor as a parameter.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The documentation specifically states that flock is meant for files. From the MacOS documentation page (man): (emphasis added)

Flock() applies or removes an advisory lock on the file associated with the file descriptor fd.

In particular, this is meant for inter-process synchronization on the same file. Assuming that you are trying to lock amongst threads within a process, it seems wise to instead rely on pthread_mutex_lock/unlock. (You are about to do a slow IO, so I woulnd't bother with spinlocks either).

Hope that helps,

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!