Mombu the Microsoft Forum sponsored links

Go Back   Mombu the Microsoft Forum > Microsoft > WINDOWS PROGRAMMING (NNTP) > fcntl() - ioctlsocket()
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 27th April 06:27
wim.deprez+google
External User
 
Posts: 1
Default fcntl() - ioctlsocket()



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
  Reply With Quote


  sponsored links


2 27th April 06:27
phil frisbie, jr.
External User
 
Posts: 1
Default fcntl() - ioctlsocket()



I always use ioctl() on *nix, which has a direct correlation to ioctlsocket() on Windows.


If you declare iMode to be an unsigned long you will not need the cast...


--
Phil Frisbie, Jr.
Hawk Software
http://www.hawksoft.com
  Reply With Quote
3 27th April 06:27
tejeswar_das
External User
 
Posts: 1
Default fcntl() - ioctlsocket()


Yes, ioctlsocket() should do the trick.

u_long iMode = 1;
ioctlsocket(sd, FIONBIO, &iMode);

However, please make sure that you have not issued a
WSAAsyncSelect/WSAEventSelect on the socket. In that case, ioctlsocket
fails with WSAEINVAL.

Regards
Tejeswar Das
  Reply With Quote
4 27th April 06:27
wim deprez
External User
 
Posts: 1
Default fcntl() - ioctlsocket()


"Phil Frisbie, Jr." <phil@hawksoft.com> escribió en el mensaje
news:MivNc.4356$54.65719@typhoon.sonic.net...


ok, thanks for the tip, but I did not write the *nix-code

yeah, you're right :-) I just copied it blank from the MSDN-site (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/wi nsock/ioctlsocket_2.asp)
  Reply With Quote
5 27th April 06:27
wim deprez
External User
 
Posts: 1
Default fcntl() - ioctlsocket()


"Tejeswar Das" <tejeswar_das@hotmail.com> escribió en el mensaje
news:3d0ad12f.0407270909.27e3f03a@posting.google.c om...

ok, thanks :-)


yeah thanks, read it on msdn and no WSA*Select in the code, so I think this
ship can sail :-)

Many kind greetings and thanks everyone,

--wim
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666