Solved

fcntl in udp socket

Posted on 2004-09-25
2
1,072 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops 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.

707 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