diff options
author | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2001-09-24 15:13:43 +0000 |
---|---|---|
committer | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2001-09-24 15:13:43 +0000 |
commit | 6929735d6320f4efa60b3d1c5f831f41b499f3d7 (patch) | |
tree | 4f45a0b53ace8d63c0e8c5dfd12ec7af3e40eeb1 /src | |
parent | d4c25f805667ae9d663ae5d4d0f6bfe0864ef81a (diff) | |
download | zabbix-6929735d6320f4efa60b3d1c5f831f41b499f3d7.tar.gz zabbix-6929735d6320f4efa60b3d1c5f831f41b499f3d7.tar.xz zabbix-6929735d6320f4efa60b3d1c5f831f41b499f3d7.zip |
- simplified tcp_listen procedure in zabbix_agentd.c
git-svn-id: svn://svn.zabbix.com/trunk@213 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src')
-rw-r--r-- | src/zabbix_agent/zabbix_agentd.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/zabbix_agent/zabbix_agentd.c b/src/zabbix_agent/zabbix_agentd.c index 7e2ca2a8..0498f5d4 100644 --- a/src/zabbix_agent/zabbix_agentd.c +++ b/src/zabbix_agent/zabbix_agentd.c @@ -146,6 +146,36 @@ void process_child(int sockfd) int tcp_listen(const char *host, const char *serv, socklen_t *addrlenp) { + int sockfd; + struct sockaddr_in serv_addr; + + if ( (sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) + { + syslog( LOG_CRIT, "socket()"); + exit(1); + } + + bzero((char *) &serv_addr, sizeof(serv_addr)); + serv_addr.sin_family = AF_INET; + serv_addr.sin_addr.s_addr = htonl(INADDR_ANY); + serv_addr.sin_port = htons(10000); + + if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) + { + syslog( LOG_CRIT, "bind()"); + exit(1); + } + + listen(sockfd, LISTENQ); + + *addrlenp = sizeof(serv_addr); + + return sockfd; +} + +/* +int tcp_listen(const char *host, const char *serv, socklen_t *addrlenp) +{ int listenfd, n; const int on=1; struct addrinfo hints, *res, *ressave; @@ -196,6 +226,7 @@ int tcp_listen(const char *host, const char *serv, socklen_t *addrlenp) return (listenfd); } +*/ void child_main(int i,int listenfd, int addrlen) { |