/[LeafOK_CVS]/lbbs/src/net_server.c
ViewVC logotype

Diff of /lbbs/src/net_server.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.112 by sysadm, Fri Dec 19 06:16:27 2025 UTC Revision 1.113 by sysadm, Thu Dec 25 05:20:09 2025 UTC
# Line 518  int net_server(const char *hostaddr, in_ Line 518  int net_server(const char *hostaddr, in_
518          int ret;          int ret;
519          int flags_server[2];          int flags_server[2];
520          struct sockaddr_in sin;          struct sockaddr_in sin;
521            char local_addr[INET_ADDRSTRLEN];
522    
523  #ifdef HAVE_SYS_EPOLL_H  #ifdef HAVE_SYS_EPOLL_H
524          struct epoll_event ev, events[MAX_EVENTS];          struct epoll_event ev, events[MAX_EVENTS];
# Line 606  int net_server(const char *hostaddr, in_ Line 607  int net_server(const char *hostaddr, in_
607                  sin.sin_addr.s_addr = (hostaddr[0] != '\0' ? inet_addr(hostaddr) : INADDR_ANY);                  sin.sin_addr.s_addr = (hostaddr[0] != '\0' ? inet_addr(hostaddr) : INADDR_ANY);
608                  sin.sin_port = htons(port[i]);                  sin.sin_port = htons(port[i]);
609    
610                    if (inet_ntop(AF_INET, &(sin.sin_addr), local_addr, sizeof(local_addr)) == NULL)
611                    {
612                            log_error("inet_ntop() error (%d)", errno);
613                            return -1;
614                    }
615    
616                  // Reuse address and port                  // Reuse address and port
617                  flags_server[i] = 1;                  flags_server[i] = 1;
618                  if (setsockopt(socket_server[i], SOL_SOCKET, SO_REUSEADDR, &flags_server[i], sizeof(flags_server[i])) < 0)                  if (setsockopt(socket_server[i], SOL_SOCKET, SO_REUSEADDR, &flags_server[i], sizeof(flags_server[i])) < 0)
# Line 622  int net_server(const char *hostaddr, in_ Line 629  int net_server(const char *hostaddr, in_
629                  if (bind(socket_server[i], (struct sockaddr *)&sin, sizeof(sin)) < 0)                  if (bind(socket_server[i], (struct sockaddr *)&sin, sizeof(sin)) < 0)
630                  {                  {
631                          log_error("Bind address %s:%u error (%d)",                          log_error("Bind address %s:%u error (%d)",
632                                            inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), errno);                                            local_addr, port[i], errno);
633                          return -1;                          return -1;
634                  }                  }
635    
# Line 632  int net_server(const char *hostaddr, in_ Line 639  int net_server(const char *hostaddr, in_
639                          return -1;                          return -1;
640                  }                  }
641    
642                  log_common("Listening at %s:%u", inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));                  log_common("Listening at %s:%u", local_addr, port[i]);
643    
644  #ifdef HAVE_SYS_EPOLL_H  #ifdef HAVE_SYS_EPOLL_H
645                  ev.events = EPOLLIN;                  ev.events = EPOLLIN;
# Line 790  int net_server(const char *hostaddr, in_ Line 797  int net_server(const char *hostaddr, in_
797  #endif  #endif
798    
799                          log_common("Reload configuration");                          log_common("Reload configuration");
800                            
801                          // Restart log                          // Restart log
802                          if (log_restart() < 0)                          if (log_restart() < 0)
803                          {                          {
# Line 931  int net_server(const char *hostaddr, in_ Line 938  int net_server(const char *hostaddr, in_
938                                                  }                                                  }
939                                          }                                          }
940    
941                                          strncpy(hostaddr_client, inet_ntoa(sin.sin_addr), sizeof(hostaddr_client) - 1);                                          if (inet_ntop(AF_INET, &(sin.sin_addr), hostaddr_client, sizeof(hostaddr_client)) == NULL)
942                                          hostaddr_client[sizeof(hostaddr_client) - 1] = '\0';                                          {
943                                                    log_error("inet_ntop() error (%d)", errno);
944                                                    close(socket_client);
945                                                    break;
946                                            }
947                                          port_client = ntohs(sin.sin_port);                                          port_client = ntohs(sin.sin_port);
948    
949                                          if (SYS_child_process_count - 1 < BBS_max_client)                                          if (SYS_child_process_count - 1 < BBS_max_client)


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1