Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

stcpopts.hh File Reference

#include "rcs_defs.hh"

Include dependency graph for stcpopts.hh:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Functions

int RCS_EXPORT set_stcp_socket_options (int socket_fd)

Variables

int stcp_nonblocking


Function Documentation

int RCS_EXPORT set_stcp_socket_options int    socket_fd
 

Definition at line 45 of file stcpopts.cc.

Referenced by STCPMEM::STCPMEM().

00046 {
00047   if (socket_fd <= 0)
00048     {
00049       return -1;
00050     }
00051   int optval = 1;
00052 #if defined(_Windows) || !defined(MSDOS)
00053   if (dl_setsockopt (socket_fd, IPPROTO_TCP, TCP_NODELAY,
00054                      (char *) &optval, sizeof (optval)) < 0)
00055     {
00056       rcs_print_error (" Can`t set a socket option.\n");
00057       rcs_print_error ("errno = %d = %s\n", errno, strerror (errno));
00058       return -1;
00059     }
00060 #endif
00061   optval = 1;
00062 
00063 #if !defined(MSDOS) || defined(_Windows)
00064   if (dl_setsockopt (socket_fd, SOL_SOCKET, SO_REUSEADDR,
00065                      (char *) &optval, sizeof (optval)) < 0)
00066     {
00067       rcs_print_error (" Can`t set a socket option.\n");
00068       rcs_print_error ("errno = %d = %s\n", errno, strerror (errno));
00069       return -1;
00070     }
00071   struct linger linger_opt;
00072   linger_opt.l_onoff = 0;
00073   linger_opt.l_linger = 0;
00074   if (dl_setsockopt (socket_fd, SOL_SOCKET, SO_LINGER,
00075                      (char *) &linger_opt, sizeof (linger_opt)) < 0)
00076     {
00077       rcs_print_error (" Can`t set a socket option.\n");
00078       rcs_print_error ("errno = %d = %s\n", errno, strerror (errno));
00079       return -1;
00080     }
00081 #endif
00082 
00083   if (stcp_nonblocking)
00084     {
00085 #ifdef _Windows
00086       unsigned long arg = 1;
00087       if (dl_ioctlsocket (socket_fd, FIONBIO, &arg) < 0)
00088         {
00089           rcs_print_error ("Can't set  socket to non-blocking.");
00090         }
00091 #else
00092 #ifndef VXWORKS
00093 #if defined(O_NDELAY) && !defined(O_NONBLOCK)
00094       if (-1 == fcntl (socket_fd, F_SETFL, O_NDELAY))
00095         {
00096           rcs_print_error ("Couldn's set flag for no delay on socket.\n");
00097         }
00098 #endif
00099 #ifdef O_NONBLOCK
00100       if (-1 == fcntl (socket_fd, F_SETFL, O_NONBLOCK))
00101         {
00102           rcs_print_error ("Couldn's set flag for non-blocking on socket.\n");
00103         }
00104 #endif
00105 #endif
00106 #endif
00107     }
00108   return (0);
00109 }


Variable Documentation

int stcp_nonblocking
 

Definition at line 11 of file stcpopts.hh.


Generated on Sun Dec 2 15:57:58 2001 for rcslib by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001