Solved

fcntl in udp socket

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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

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…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

773 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