Solved

fcntl in udp socket

Posted on 2004-09-25
2
1,062 Views
Last Modified: 2006-11-17
i have a udp socket that uses fcntl to create a non blocking socket. However , i am getting my packets with delay even though i have cleared the non blocking flag before setting it up . any help will be appreciated.
0
Comment
Question by:webusername
2 Comments
 
LVL 23

Accepted Solution

by:
Mysidia earned 500 total points
ID: 12153283
Another possibility to enable non-blocking I/O for your sockets is...

#include <sys/ioctl.h>
...

int value = 1;
if ( ioctl(file_descriptor_here, FIONBIO, &value) == -1) {
      /* handle error */
}

Non-blocking I/O doesn't mean there won't be any delay in the transmission
but that when data is received, a call won't cause your program to wait idle
(stay in the read/write call) to await everything to come in before returning control to the program.

Even with non-blocking I/O it may be needed to wait for info to arrive with an event loop using
select() or poll() to wait for writability / waiting input..
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 12157706
Hi webusername,

Can you elaborate your query a bit?

>create a non blocking socket.
please post those few lines of code where you have done this

>However , i am getting my packets with delay even though i have cleared the non blocking flag before setting it up .
How did you know there was a delay? As Mysidia pointed out, non-blocking sockets simply means that your read and write calls to that socket will not block for completion. Rather if for some reason, request cannot be satisfied at that time, they will return with error numer EAGAIN.
0

Featured Post

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question