Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How can i assign different IP addresses to different Programs  RSS feed

 
David Nelson
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, all

I'm trying to write some programs to simulate a network environment, how can i assign different IP addresses to different programs.

Once i assign them with different IP addresses, how could Pro1 with IP address 2001:0:0:1::/64 find Pro2 with IP address 2000:0:0:2::/64.

one thing is these programs run on the same machine!

Cheers
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to Sockets and Internet Protocals forum.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Usually a machine has a single IP address. I don't know what happens to a machine with multiple NIC cards. But you can have different port numbers, so you could run one server process listening on 127.0.0.1:8080 and another on 127.0.0.1:8181. Would that do the trick for you?
 
peter wooster
Ranch Hand
Posts: 1033
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Stan James:
Usually a machine has a single IP address. I don't know what happens to a machine with multiple NIC cards. But you can have different port numbers, so you could run one server process listening on 127.0.0.1:8080 and another on 127.0.0.1:8181. Would that do the trick for you?


A machine has one address for every interface, NICs usually have one interface each. So you will have one address for each NIC. There are programs that produce Virtual IP Addresses (VIPA), these are mostly available on large IBM servers (OS/390 mainframes). There is an old hack for the Sun OS kernel that will do this.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!