🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.programmer
Article #3498

Re: Coding for Multiple IP addresses

#3498
From: Chris Liechti
Date: Thu, 04 Oct 2001 20:12
38 lines
2095 bytes
"csteow" <chinsiang@csksoftware.com.sg> wrote in
news:9pgjkm$3rv$1@newton3.pacific.net.sg: 

> Hi:
> 
> I plan to have a machine with 3 IP addresses and I run my app to listen
> to port 9000.  How to do socket programming on handling multiple IP to
> listen to same port? Is it using "bind()" and use "select()" to pass in
> the three socket handle?

I don't know the C semantics but ususaly you use "bind" to install your 
server socket and as argument you can give an IP address, which will mean 
that you bind *only* to that address. If you want to bind to *all* network 
interfaces you use "INADDR_ANY" (0.0.0.0).

if you have linux try "man 7 ip", "man 2 bind", "man socket"
 
> I can't try on my own since I don't own multiple IP machine, could
> anybody tell me that  what I mention on above correct?

Yes you do, if you have one ethernet card or dialup. The other address is 
127.0.0.1 and is called "localhost". Its the local loopback device which 
lets you test any network software on the local machine.


> Thanks.
> 
> Regards,
> Chin Siang
> 
> 
> 



-- 
Chris <cliechti@gmx.net>
Technical Details
Message-ID: <Xns9130E213DA29Fcliechtigmxnet@62.2.16.82>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.cwix.com!news.swissonline.ch
References: <9pgjkm$3rv$1@newton3.pacific.net.sg>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,5c28fb306d42b63c
X-Google-Attributes: gid11318c,public
X-Google-Thread: fc89c,5c28fb306d42b63c
X-Google-Attributes: gidfc89c,public
X-Google-Thread: f65d0,5c28fb306d42b63c
X-Google-Attributes: gidf65d0,public
X-Google-ArrivalTime: 2001-10-04 13:12:41 PST
Newsgroups: comp.unix.programmer,gnu.gcc,gnu.gcc.help
Subject: Re: Coding for Multiple IP addresses
From: Chris Liechti <cliechti@gmx.net>
References: <9pgjkm$3rv$1@newton3.pacific.net.sg>
Message-ID: <Xns9130E213DA29Fcliechtigmxnet@62.2.16.82>
User-Agent: Xnews/4.06.22
NNTP-Posting-Host: 217.162.157.223
Date: 4 Oct 2001 22:12:35 +0200
X-Trace: news.swissonline.ch 1002226355 217.162.157.223 (4 Oct 2001 22:12:35 +0200)
Lines: 39
X-Complaints-To: news@swissonline.ch
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.cwix.com!news.swissonline.ch