(E-Mail Removed) wrote:
> As an intermediary measure I have constructed a thread that monitors
> the IP address of the adapters and if they change it restarts the
> networked side of my application. This seems a bit like a kludge;
> surely this is something that people must come up against all the time,
> for instance writers of windows services must have to take this into
> account not only for start up, but also when a user does something like
> ipconfig /renew, which could very well change the IP. Is there an
> elegant way of doing what I'm trying to do, or indeed is there a way
> that I can bind a socket to a physical adapter and not an IP address?
> Oh and I'm working in C#, but if someone has a compelling reason to
> switch to native code I'm game.
In addition to the suggestions others have made, to get a signal when
interfaces are added or deleted, have you considered simply binding to IP
address 0.0.0.0 ( INADDR_ANY ), so that you get _all_ incoming data on _all_
interfaces, new or old?
If you're using TCP, the getsockname() function will tell you on which
address the accepted socket has been accepted, if you need to know that
information.
If you're using UDP, getsockname() may not be reliable.
Alun.
~~~~
[Please don't email posters, if a Usenet response is appropriate.]
--
Texas Imperial Software | Find us at
http://www.wftpd.com or email
23921 57th Ave SE |
(E-Mail Removed).
Washington WA 98072-8661 | WFTPD, WFTPD Pro are Windows FTP servers.
Fax/Voice +1(425)807-1787 | Try our NEW client software, WFTPD Explorer.