1

So I have a known working version of this code on Windows and MacOSX:

int CSocket::setsync(int mode)
{
    if(sockid < 0)return -1;
    u_long i = mode;
    return ioctlsocket(sockid, FIONBIO, &i);
}

I just want to know if the following Linux version is functionally equivalent:

int CSocket::setsync(int mode)
{
    if(sockid < 0)return -1;
    u_long i = mode;
    return ioctl(sockid, FIONBIO, &i);
}

Just an FYI, i #included sys/ioctl.h

nhed
  • 5,774
  • 3
  • 30
  • 44
Nicholas Terry
  • 1,812
  • 24
  • 40
  • What? No, i used the line #include – Nicholas Terry Jul 08 '12 at 02:50
  • 1
    Check out [UNIX nonblocking I/O: O_NONBLOCK vs. FIONBIO](http://stackoverflow.com/q/1150635/1380680) for a better alternative on Linux using `fcntl`. [This one](http://stackoverflow.com/q/3255899/1380680) is also interesting. – Reinier Torenbeek Jul 08 '12 at 02:52

1 Answers1

1

So i answered my own question. As far as I can tell, they are. At least, the code seems to function. If you want to see the code in action, clone the code at https://github.com/nterry/39DLL-4-Linux

Nicholas Terry
  • 1,812
  • 24
  • 40