How to make a nonblocking receive socket?

This is a discussion on How to make a nonblocking receive socket? within the Windows Programming forums, part of the Platform Specific Boards category; Hi, all How to create a no blocking/waiting socket for receiving? So that if there is no incoming data available ...

  1. #1
    Registered User
    Join Date
    Dec 2002
    Posts
    162

    Unhappy How to make a nonblocking receive socket?

    Hi, all

    How to create a no blocking/waiting socket for receiving?
    So that if there is no incoming data available for the socket at the function "recvfrom" it would continue instead of waiting for incoming data. Can you make the socket nonblocking or must you make the recievning function nonblocking? Is it possible to do this without having multithreads or network events?
    We haven't inherited Earth from our parents; instead we have borrowed her from our children - old Indian saying.

  2. #2
    Registered User
    Join Date
    Dec 2002
    Posts
    162
    I can't seem to find the functions FD_ZERO() and FD_SET()?
    What header to a need to include?
    We haven't inherited Earth from our parents; instead we have borrowed her from our children - old Indian saying.

  3. #3
    Registered User
    Join Date
    Dec 2002
    Posts
    162
    OK sorry... I thought they where function... and when they didn't show any tooltip info (i VC++) I thought they wheren't declared.

    I tested your code but it didn't work, the recvfrom() still blocked.
    I also tested changing the timeout time but that didn't help.

    The socket I am trying to make nonblocking is an UDP socket that is unconnected.
    We haven't inherited Earth from our parents; instead we have borrowed her from our children - old Indian saying.

  4. #4
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856
    The point of using select is to call recvfrom() only when there is indeed something to receive. This is the nonblocking aspect of what you're doing. Instead of always trying to receive you do it when there's data.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple Socket Library Not so simple
    By jbully in forum C Programming
    Replies: 4
    Last Post: 12-23-2010, 09:23 AM
  2. Makefile Problem: None rule to make target
    By chris24300 in forum Linux Programming
    Replies: 25
    Last Post: 06-17-2009, 10:45 AM
  3. looking for non-MFC based socket programming sample
    By George2 in forum Networking/Device Communication
    Replies: 1
    Last Post: 06-19-2006, 06:57 AM
  4. Win32 Common Controls in C++, how do i make and use them?
    By C+noob in forum Windows Programming
    Replies: 6
    Last Post: 01-09-2006, 11:53 AM
  5. Socket code problems
    By Phan in forum Networking/Device Communication
    Replies: 10
    Last Post: 09-14-2005, 05:23 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21