Difference for socket/init.c from version 1.7 to 1.8


version 1.7 version 1.8
Line 1
 
Line 1
   
 /*  /*
  * static char *rcsid_init_c =   * static char *rcsid_init_c =
  *    "$Id: init.c,v 1.7 2001/02/03 05:30:18 cvs Exp $";   *    "$Id: init.c,v 1.8 2001/04/06 00:43:12 michtoen Exp $";
  */   */
   
 /*  /*
Line 37
 
Line 37
 #ifndef __CEXTRACT__  #ifndef __CEXTRACT__
 #include <sproto.h>  #include <sproto.h>
 #endif  #endif
   #ifndef WIN32 //---win32 exclude include files
 #include <sys/types.h>  #include <sys/types.h>
 #include <sys/time.h>  #include <sys/time.h>
 #include <sys/socket.h>  #include <sys/socket.h>
 #include <netinet/in.h>  #include <netinet/in.h>
 #include <netdb.h>  #include <netdb.h>
   #endif // win32
   
 #ifdef HAVE_UNISTD_H  #ifdef HAVE_UNISTD_H
 #include <unistd.h>  #include <unistd.h>
Line 50
 
Line 52
 #ifdef HAVE_ARPA_INET_H  #ifdef HAVE_ARPA_INET_H
 #include <arpa/inet.h>  #include <arpa/inet.h>
 #endif  #endif
   
 #include <newserver.h>  #include <newserver.h>
   
 Socket_Info socket_info;  Socket_Info socket_info;
Line 167
 
Line 168
     int oldbufsize;      int oldbufsize;
     int buflen=sizeof(int);      int buflen=sizeof(int);
   
   #ifdef WIN32 // ***WIN32 SOCKET: init win32 non blocking socket
    int temp = 1;
   
    if(ioctlsocket(ns->fd, FIONBIO , &temp) == -1)
    LOG(llevError,"InitConnection:  Error on ioctlsocket.\n");
   #else
     if (fcntl(ns->fd, F_SETFL, O_NDELAY)==-1) {      if (fcntl(ns->fd, F_SETFL, O_NDELAY)==-1) {
  LOG(llevError,"InitConnection:  Error on fcntl.\n");   LOG(llevError,"InitConnection:  Error on fcntl.\n");
     }      }
   #endif // end win32
   
     if (getsockopt(ns->fd,SOL_SOCKET,SO_SNDBUF, (char*)&oldbufsize, &buflen)==-1)      if (getsockopt(ns->fd,SOL_SOCKET,SO_SNDBUF, (char*)&oldbufsize, &buflen)==-1)
  oldbufsize=0;   oldbufsize=0;
     if (oldbufsize<bufsize) {      if (oldbufsize<bufsize) {
Line 237
 
Line 246
     struct protoent  *protox;      struct protoent  *protox;
     struct linger linger_opt;      struct linger linger_opt;
   
   #ifdef WIN32 // ***win32  -  we init a windows socket
    WSADATA w;
   
    socket_info.max_filedescriptor = 1; // used in select, ignored in winsockets
    WSAStartup (0x0101,&w); // this setup all socket stuuf
    // ill include no error tests here, winsocket 1.1 should always work
    // except some old win95 versions without tcp/ip stack
   #else // non windows
   
 #ifdef HAVE_SYSCONF  #ifdef HAVE_SYSCONF
   socket_info.max_filedescriptor = sysconf(_SC_OPEN_MAX);    socket_info.max_filedescriptor = sysconf(_SC_OPEN_MAX);
 #else  #else
Line 246
 
Line 264
   "Unable to find usable function to get max filedescriptors";    "Unable to find usable function to get max filedescriptors";
 #  endif  #  endif
 #endif  #endif
   #endif // win32
   
     socket_info.timeout.tv_sec = 0;      socket_info.timeout.tv_sec = 0;
     socket_info.timeout.tv_usec = 0;      socket_info.timeout.tv_usec = 0;
Line 265
 
Line 284
   
     protox = getprotobyname("tcp");      protox = getprotobyname("tcp");
     if (protox==NULL) {      if (protox==NULL) {
  LOG(llevError,"init_ericserver: Error getting protox");   LOG(llevError,"init_ericserver: Error getting protox\n");
  return;   return;
     }      }
     init_sockets[0].fd = socket(PF_INET, SOCK_STREAM, protox->p_proto);      init_sockets[0].fd = socket(PF_INET, SOCK_STREAM, protox->p_proto);
Line 291
 
Line 310
  */   */
 #if defined(__osf__) || defined(hpux) || defined(sgi) || defined(NeXT) || \  #if defined(__osf__) || defined(hpux) || defined(sgi) || defined(NeXT) || \
         defined(__sun__) || defined(linux) || defined(SVR4) || defined(__FreeBSD__) || \          defined(__sun__) || defined(linux) || defined(SVR4) || defined(__FreeBSD__) || \
  defined(__OpenBSD__)   defined(__OpenBSD__) || defined(WIN32) // ---win32 add this here
     {      {
  char tmp =1;   char tmp =1;
   
Line 310
 
Line 329
     if (bind(init_sockets[0].fd,(struct sockaddr *)&insock,sizeof(insock)) == (-1)) {      if (bind(init_sockets[0].fd,(struct sockaddr *)&insock,sizeof(insock)) == (-1)) {
  perror("error on bind command");   perror("error on bind command");
  LOG(llevError,"error on bind command\n");   LOG(llevError,"error on bind command\n");
   #ifdef WIN32 // ***win32: close() -> closesocket()
    shutdown(init_sockets[0].fd,SD_BOTH);
    closesocket(init_sockets[0].fd);
   #else
  close(init_sockets[0].fd);   close(init_sockets[0].fd);
   #endif // win32
  exit(-1);   exit(-1);
     }      }
     if (listen(init_sockets[0].fd,5) == (-1))  {      if (listen(init_sockets[0].fd,5) == (-1))  {
  perror("error on listen");   perror("error on listen");
  LOG(llevError,"error on listen\n");   LOG(llevError,"error on listen\n");
   #ifdef WIN32 // ***win32: close() -> closesocket()
    shutdown(init_sockets[0].fd,SD_BOTH);
    closesocket(init_sockets[0].fd);
   #else
  close(init_sockets[0].fd);   close(init_sockets[0].fd);
   #endif // win32
  exit(-1);   exit(-1);
     }      }
     init_sockets[0].status=Ns_Add;      init_sockets[0].status=Ns_Add;
Line 354
 
Line 383
   
 void free_newsocket(NewSocket *ns)  void free_newsocket(NewSocket *ns)
 {  {
   #ifdef WIN32 // ***win32: closesocket in windows style
    shutdown(ns->fd,SD_BOTH);
       if (closesocket(ns->fd)) {
   #else
     if (close(ns->fd)) {      if (close(ns->fd)) {
   #endif // win32
   
 #ifdef ESRV_DEBUG  #ifdef ESRV_DEBUG
  LOG(llevDebug,"Error closing socket %d\n", which);   LOG(llevDebug,"Error closing socket %d\n", ns->fd);
 #endif  #endif
     }      }
     if (ns->stats.range)      if (ns->stats.range)


Legend:
line(s) removed in v.1.7 
line(s) changed
 line(s) added in v.1.8

File made using version 1.98 of cvs2html by leaf at 2011-07-21 19:34