Connect two ip addresses in different subnet

I have two computers with two different ip addresses and subnet masks.
Computer1: ip address 10.57.x.x with subnet mask
Computer2: ip address 10.1.y.y with subnet mask, gateway 10.1.y.z

I need to write a C++ program in Computer1 which connects to Computer2 through an ethernet cross-over cable. What is the best way to do it?

Could it be possible to add another ip address 10.1.y.z in Computer 1 and pretend the gateway to communicate with Computer2? Any suggestions will be appreciated.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bill BachPresident and Btrieve GuruCommented:
A few ideas...

1) Is this a one-time transfer?  A crossover cable will not allow other communications anyway, so the IP addresses really wouldn't matter.  Just re-address one of the two boxes to the same subnet as the other one.  When you're done, re-address the machine back and plug it back into the 'Net.

2) Look into products like LapLink that allow transfer via USB, Serial, or Parallel cables instead.  Much easier to implement and you don't have to touch the networking side of things.

3) Depending on the OS, you may be able to add a second IP address to the existing NIC.  However, with a cross-over cable in use, this is a waste of effort, since the other IP address will be useless anyway.

4) You could simply add a second NIC, which is easy enough to do on most OS'es, and configure THAT one for your cross-over network link.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ssl1324Author Commented:
Thanks for your reply.

The ip addresses and subnet masks must be fixed. And the communication protocol has to be TCP/IP (i.e. through ethernet crossover cable).

Another requirement I forget to mention is that, Computer2 only accepts the fixed ip address which connects to it (i.e. only accept ip address 10.57.x.x). So Computer2 will check the TCP header and reject the connection if the ip address is not 10.57.x.x.

I have thought about adding another NIC but any other software suggestion will be appreciated.
Bill BachPresident and Btrieve GuruCommented:
Why such strange requirements?  There is simply no way that this even makes sense in the typical world of computing.  Is this for a class assignment? Sounds like an ideal project for an OS/networking course to explore the innards of device drivers.

The only viable solution, given the constraints that you have provided, is to write your own version of an IP stack that makes the changes as you need them.  

If you can add additional devices in-line with the cross-over cable, then there are other options, such as adding a router in between the boxes, or even creating your own version of The Bongo Project ( to implement your own physical layer in place of the Ethernet cross-over cable.  However, this does not follow your original specs.
Unless I completely don't understand what your trying to do BillBach is right this is a strange request/requirement. the two pc's simply will not talk to each other through a crossover cable with statically assinged ip's in different subnets. You could add another IP address to computer 2 on the same subnet as computer one and then they could communicate
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.