diff options
author | wens <wens@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-03-02 00:26:11 +0800 |
---|---|---|
committer | wens <wens@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-03-02 00:26:11 +0800 |
commit | 11cf3f25d98f02e3e02984b5e372159d9b6c555b (patch) | |
tree | a39555c4a537b8badff597bbfde9c4ee68558ef5 /mbbsd | |
parent | d2b177e6004b566092ba398664e3a71b8a405971 (diff) | |
download | pttbbs-11cf3f25d98f02e3e02984b5e372159d9b6c555b.tar pttbbs-11cf3f25d98f02e3e02984b5e372159d9b6c555b.tar.gz pttbbs-11cf3f25d98f02e3e02984b5e372159d9b6c555b.tar.bz2 pttbbs-11cf3f25d98f02e3e02984b5e372159d9b6c555b.tar.lz pttbbs-11cf3f25d98f02e3e02984b5e372159d9b6c555b.tar.xz pttbbs-11cf3f25d98f02e3e02984b5e372159d9b6c555b.tar.zst pttbbs-11cf3f25d98f02e3e02984b5e372159d9b6c555b.zip |
able to choose ip to bind
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2568 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r-- | mbbsd/stuff.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/mbbsd/stuff.c b/mbbsd/stuff.c index 3e44efdf..ba3253bf 100644 --- a/mbbsd/stuff.c +++ b/mbbsd/stuff.c @@ -955,7 +955,7 @@ time4_t time4(time4_t *ptr) #endif #ifdef OUTTACACHE -int tobind(int port) +int tobind(char * host, int port) { int sockfd, val; struct sockaddr_in servaddr; @@ -968,7 +968,10 @@ int tobind(int port) (char *)&val, sizeof(val)); bzero(&servaddr, sizeof(servaddr)); servaddr.sin_family = AF_INET; - servaddr.sin_addr.s_addr = htonl(INADDR_ANY); + if (!host || host[0] == NULL) + servaddr.sin_addr.s_addr = htonl(INADDR_ANY); + else if (inet_aton(host, &servaddr.sin_addr) == 0) + err(1, NULL); servaddr.sin_port = htons(port); if( bind(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr)) < 0 ) { perror("bind()"); |