I challenge anyone to code this in C language:

function read_next_data(fd)
data = read_async( fd )
if len(data) == 0
=> Nothing to read, register to be called back when something is ready
event_polling_register( fd, read_next_data )
=> Go back to doing something else
else
=> Data was available and len(data) was received
add_data_to_buffer( buffer, data )
fi

What makes you think it can't be done in C? win32 api has quite a few functions that require callback functions from the application program. I suspect (but don't know) that *nix does too. callback functions like that are often used in serial communications, such as data arriving on COM1 or COM2 ports, and socket programming.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.