fcntl() - ioctlsocket()
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > fcntl() - ioctlsocket()




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    fcntl() - ioctlsocket()  
Wim Deprez


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-28-04 11:19 PM

Hi Group,

for porting issues, I need to translate a fcntl(). In the original
*nix-code the following is used:

fcntl(sd, F_SETFL, O_NONBLOCK);

to make sd a non blocking socket. Now I was wondering if

// If iMode = 0, blocking is enabled;
// If iMode != 0, non-blocking mode is enabled.
int iMode = 1;
ioctlsocket(sd, FIONBIO, (u_long FAR*) &iMode)

contains the same behaviour for win32 systems.

Many kind greetings,

--wim





[ Post a follow-up to this message ]



    Re: fcntl() - ioctlsocket()  
Lev Walkin


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-28-04 11:19 PM

Wim Deprez wrote:
> Hi Group,
>
> for porting issues, I need to translate a fcntl(). In the original
> *nix-code the following is used:
>
>    fcntl(sd, F_SETFL, O_NONBLOCK);
>
> to make sd a non blocking socket. Now I was wondering if
>
>    // If iMode = 0, blocking is enabled;
>    // If iMode != 0, non-blocking mode is enabled.
>    int iMode = 1;
>    ioctlsocket(sd, FIONBIO, (u_long FAR*) &iMode)
>
> contains the same behaviour for win32 systems.

You'd better ask in Winsock programming group, like
alt.winsock.programming.

However, it is easy to test: just open a connection
to a remote host and execute the following:

int r;
char buf;

r1 = read(fd, &buf, 1);

assert(r1 == -1 && errno == EAGAIN);

or something similar.

(make sure the remote host does not send anything.
www.com:80 will do).

--
Lev Walkin
vlm@lionet.info





[ Post a follow-up to this message ]



    Re: fcntl() - ioctlsocket()  
Daniel Rakel


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-28-04 11:19 PM

Wim Deprez wrote:

> for porting issues, I need to translate a fcntl(). In the original
> *nix-code the following is used:
>
>    fcntl(sd, F_SETFL, O_NONBLOCK);
>
> to make sd a non blocking socket. Now I was wondering if

If you only want to switch from blocking to non-blocking mode, you should
first get the current flags, add O_NONBLOCK and then set these flags.
The above code would clear the current flags set.

Regards,
Daniel





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 11:25 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register