Solved

fcntl in udp socket

Posted on 2004-09-25
2
1,047 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
Comment Utility
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
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now