Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9104711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:55:50+00:00 2026-06-17T01:55:50+00:00

When i was taking a look at setsockopt from msdn link . i came

  • 0

When i was taking a look at setsockopt from msdn link. i came across a parameter SO_RCVTIMEO, it description is “Sets the timeout, in milliseconds, for blocking receive calls.” I thought the socket listen operation is event driven which means when kernel drained frame from NIC card it notify my program socket, so what is the blocking all about?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T01:55:51+00:00Added an answer on June 17, 2026 at 1:55 am

    The recv and WSARecv functions are blocking. They are not event driven (at least not at the calling level). Even when blocking has a timeout (as set with the SO_RECTIMEO option), they are not event driven as far as your code is concerned. In that case, they are just pseudo-blocking (arguably non-blocking depending on how short the timeout is).

    When you call WSARecv, it will wait until data is ready to be read. While data is not ready to be read, it just waits. This is why it’s considered blocking.


    You are correct that at it’s core networking is event driven. Under the hood, computers are, by nature, event driven. It’s the way hardware works. Hardware interrupts are essentially events. You’re right that at a low level what is happening is that your NIC card is telling the OS that it’s ready to be read. At that level, it is indeed event based.

    The problem is that WSARecv waits for that event.


    Here’s a hopefully clear analogy. Imagine that you for some reason cannot leave your house. Now imagine that your friend F lives next door. Additionally, assume that your other friend G is at your house.

    Now imagine that you give G a piece of paper with a question on it and ask him to take it to F.

    Once the question has been sent, imagine that you send G to go get F’s response. This is like the recv call. G will wait until F has written down his response, then he will bring it to you. G does not immediately turn around and come back if F hasn’t written it yet.

    This is where the gap comes from. G is indeed aware of the “F wrote!” events, but you’re not. You’re not directly watching the piece of paper.

    Setting a timeout means that you’re telling G to wait at most some amount of time before giving up and coming back. In this situation, G is still waiting on F to write, but if F doesn’t write within x milliseconds, G turns around and comes back empty handed.

    Basically the pseudo code of recv is vaguely like:

    1) is data available?
      1a) Yes: read it and return
      1b) No: GOTO 2
    2) Wait until an event is received
      2a) GOTO 1
    

    I know this has been a horribly convoluted explanation, but my main point is this: recv is interacting with the events, not your code. recv blocks until one of those events is received. If a timeout is set, it blocks until either one of those events is received, or the timeout is reached.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After taking a look at theming for Fede's UberMusic I came across the file
I'm taking a look at how to properly escape data that comes from the
I'm taking a look at updating from the deprecated (in Rails 3.1) use of
Taking a look at my question HERE , I now want to return the
After taking a look at this SO question and doing my own research, it
Thanks for taking a look at this. The issue has to do with the
I was taking a look at Star Schema Benchmark and then I was thinking
I'm now taking a look at the PocketC powerful tool, but there is an
I'm taking a look at some random Icecast playlists (available here: http://dir.xiph.org/index.php ) and
I am finalizing one of my projects and taking a look over the whole

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.