pike.git / src / modules / _Stdio / file.c

version» Context lines:

pike.git/src/modules/_Stdio/file.c:114:   #undef NOERROR   #endif /* NOERROR */      #ifdef HAVE_NETDB_H   #include <netdb.h>   #endif   #ifdef HAVE_NET_NETDB_H   #include <net/netdb.h>   #endif /* HAVE_NET_NETDB_H */    + #ifdef HAVE_NETINET_TCP_H + #include <netinet/tcp.h> + #endif +    #include "dmalloc.h"         #undef THIS   #define THIS ((struct my_file *)(Pike_fp->current_storage))   #define FD (THIS->box.fd)   #define ERRNO (THIS->my_errno)      #define READ_BUFFER 8192   #define DIRECT_BUFSIZE (64*1024)
pike.git/src/modules/_Stdio/file.c:4902:    ERRNO = errno = ENOTTY;   #else /* !ENOTTY */    ERRNO = errno = EIO;   #endif /* ENOTTY */   #endif /* ENOTSUP */   #endif /* SO_KEEPALIVE */    pop_n_elems(args);    push_int(!i);   }    + /*! @decl int(0..1) setsockopt(int opt,int(0..1) on_off) +  *! +  *! Set socket options like Stdio.SO_KEEPALIVE. This function is always +  *! available; the presence or absence of the option constants indicates +  *! availability of those features. +  *! +  *! @returns +  *! 1 if successful, 0 if not (and sets errno()) +  *! +  *! @seealso +  *! @[set_keepalive()] +  */ + static void file_setsockopt(INT32 args) + { +  int tmp, i, opt; +  INT_TYPE o, t; +  +  get_all_args("setsockopt", args, "%i%i", &o, &t); +  +  /* In case int and INT_TYPE have different sizes */ +  tmp = t; opt = o; +  +  i = fd_setsockopt(FD, SOL_SOCKET, opt, (char *)&tmp, sizeof(tmp)); +  if(i) +  { +  ERRNO=errno; +  }else{ +  ERRNO=0; +  } +  pop_n_elems(args); +  push_int(!i); + } +    #ifdef HAVE_SYS_UN_H   #include <sys/un.h>      #ifndef PATH_MAX   #ifdef _POSIX_PATH_MAX   #define PATH_MAX _POSIX_PATH_MAX   #else /* !_POSIX_PATH_MAX */   #define PATH_MAX 255 /* Minimum according to POSIX. */   #endif /* _POSIX_PATH_MAX */   #endif /* !PATH_MAX */
pike.git/src/modules/_Stdio/file.c:6243: Inside #if defined(DN_MULTISHOT)
  #ifdef DN_MULTISHOT    /*! @decl constant DN_MULTISHOT    *! Used in @[File.notify()]. If DN_MULTISHOT is used, signals will    *! be sent for all notifications the program has registred for. Otherwise    *! only the first event the program is listening for will be received and    *! then the program must reregister for the events to receive futher events.    */    add_integer_constant("DN_MULTISHOT", DN_MULTISHOT, 0);   #endif    + #ifdef TCP_NODELAY +  /*! @decl constant TCP_NODELAY +  *! Used in @[File.setsockopt()] to control Nagle's Algorithm. +  */ +  add_integer_constant("TCP_NODELAY", TCP_NODELAY, 0); + #endif +  + #ifdef SO_KEEPALIVE +  /*! @decl constant SO_KEEPALIVE +  *! Used in @[File.setsockopt()] to control TCP/IP keep-alive packets. +  */ +  add_integer_constant("SO_KEEPALIVE", SO_KEEPALIVE, 0); + #endif +     add_integer_constant("__HAVE_OOB__",1,0);   #ifdef PIKE_OOB_WORKS    add_integer_constant("__OOB__",PIKE_OOB_WORKS,0);   #else    add_integer_constant("__OOB__",-1,0); /* unknown */   #endif      #ifdef HAVE_SYS_UN_H    add_integer_constant("__HAVE_CONNECT_UNIX__",1,0);   #endif