File: setnonblock.cpp

package info (click to toggle)
ctorrent 1.3.4.dnh3.3.2-5
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 1,240 kB
  • sloc: cpp: 13,161; sh: 675; ansic: 383; makefile: 6
file content (25 lines) | stat: -rw-r--r-- 384 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "./setnonblock.h"

#ifdef WINDOWS

int setfd_nonblock(SOCKET socket)
{
  unsigned long val = 1;
  return ioctl(socket,FIONBIO,&val);
}

#else

#include <unistd.h>
#include <fcntl.h>

int setfd_nonblock(SOCKET socket)
{
  int f_old;
  f_old = fcntl(socket,F_GETFL,0);  
  if( f_old < 0 ) return -1;  
  f_old |= O_NONBLOCK;  
  return (fcntl(socket,F_SETFL,f_old));
}

#endif