Using multiple IP addresses in a pc

Using multiple IP addresses in a pc

Post by Yogeshw » Tue, 11 Feb 2003 18:52:29



HELLO FOLKS,
  Iam trying to learn bsd socket programing.Iam working in my pc with
mandrake linux installed.I have written a clt and server prg for UDP.I
manully bind addresses for them when i execute these prgs in diff
virtual terminals for client or server  i get a message address in
use(I can execute ony one of those  progs).is there any way to
simulate and work these prgs in a pc.pl help me.
                   regards
                    Yogesh
 
 
 

Using multiple IP addresses in a pc

Post by Phil Frisbie, Jr » Wed, 12 Feb 2003 02:30:29



> HELLO FOLKS,
>   Iam trying to learn bsd socket programing.Iam working in my pc with
> mandrake linux installed.I have written a clt and server prg for UDP.I
> manully bind addresses for them when i execute these prgs in diff
> virtual terminals for client or server  i get a message address in
> use(I can execute ony one of those  progs).is there any way to
> simulate and work these prgs in a pc.pl help me.

You only need to use the same port for the client and server if you are using
broadcast or maybe multicast. Otherwise, the clients should use a system
assigned port by binding to port 0;

If you really need to use the same port, then set the SO_REUSEADDR socket option
before you bind to the port. Do this on your client and server code.

--
Phil Frisbie, Jr.
Hawk Software
http://www.hawksoft.com

 
 
 

Using multiple IP addresses in a pc

Post by Yogeshw » Fri, 14 Feb 2003 20:50:38


Dear Phil,
         Thanks a lot for ur suggestion.I made the client use a system
assigned port
I also added some dummy IP addresses to be assigned for the clien in
the file etc/hosts and assigned these addresses to
clients
Now it works like a network
Could you please tell why this started working  what i did was a blind
guess
Thankx
yogeshwar.S