Click to See Complete Forum and Search --> : Client-Server Socket programing in C++ with Two LAN cards in Client PC


zakirhussain
April 7th, 2008, 05:26 AM
I have a small network of 7 computers which communicate with each other in Client-Server relationship using socket programming technique in C. At present, one windows-XP based computer is acting as a Client while all the others are servers. Out of six servers, five are DOS based old P-I/486 and one is SUN System. Currently all the computers on the network are connected physically through Ethernet via network SWITCH & are serving the purpose.

But new requirement is to isolate the SUN Server from other DOS based Servers to minimize data collision. For this, I am required to use two LAN cards instead of one in Client which is you know Windows based. This way, on one side it could connect with SUN machine using its one IP and on the other side to 5 servers using its other IP. In other words, on one side the Client will be interfaced with 5 dos-based PCs through SWITCH and on the other side it will have direct connection with the SUN using cross-cable.
The IP addresses of all the Servers and that of the Client are in the same range. That is they are like: 100.200.202.x where the last byte varies. With two LAN cards I tried but the Client failed to connect to SUN server.
Another restriction is that the IP address of the SUN machine should not be changed as it is being used elsewhere also.

How will the Client with two LAN cards determine that the SUN Server should be connected through one particular LAN card (pre-assigned and devoted for SUN via x-cable) and not through its other LAN card?
Keeping in view the above how can I meet the said requirement?
How can I address this issue through software? Is it possible this way or what else other way out? Please help!

Edders
April 7th, 2008, 05:59 AM
To make the two Ethernet interfaces work properly in your client PC you need to give each interface an IP address within a different (sub)network. For example, your existing interface will keep its 100.200.202.x number, but the new interface that you added will have a number in a different range, like 100.200.201.x (where I changed 202 into 201). You need to change the IP address of the Sun system similarly.

Now you have basically two networks connected to your client PC. One with the DOS servers and one with the Sun. Both networks have a different IP address range which allows Windows to route the data packets to the correct network depending on the destination IP address. You do not need to do anything programatically - the routing within Windows should now take care of it.

To be honest I'm not entirely sure about the "data collision" bit. If you are using a proper full-duplex switch on the network then the single client will never have any collisions at all. Even if the servers would be "chatting" amongst themselves. Only if you'd replace the switch with a (half-duplex) hub you'll be seeing collisions.

zakirhussain
April 8th, 2008, 01:34 AM
Thanks a lot for quick and useful response.But the problem is I am not allowed to change the IP address of SUN server. What is solution then through software or any other way?

Edders
April 8th, 2008, 03:53 AM
Change the IP addresses of the DOS servers... But I have the feeling that you are not allowed to do that either...?

Depending on the actual IP addresses used by the several servers you may be able to use the netmask to divide your current range into two separate subnets, each on its own interface on the client PC.

zakirhussain
April 17th, 2008, 11:28 PM
Thanks a lot for informative input! Ok maybe I change the IP addresses of DOs servers. But your suggestion of subnet technique seems more plausible and acceptable ofcourse. Please try to elaborate this scheme as how to implement it.
Currently following setting is in place:
-> Subnet mask=255.255.255.0 for all pcs
-> Dos servers Ips:
100.100.110.101
100.100.110.102
....
....
so on upto
100.100.110.105
-> SUN server IP:
100.100.110.200
-> client IP:
100.100.110.100

In veiw of the above info please try to give a practical solution in detail which I may find easy to implemant.

Edders
April 18th, 2008, 11:16 AM
You can find more information on subnetting here (http://www.ralphb.net/IPSubnet/subnet.html). A very helpful subnet calculator can be found here (http://www.subnet-calculator.com/subnet.php?net_class=A).

If you use a netmask of 255.255.255.128 then you divide your current IP address numbering space into two separate networks -

from 100.100.110.1 to 100.100.110.126
from 100.100.110.129 to 100.100.110.254

As you can see, your DOS systems fall into one half and the Sun system falls into the other half. The interface connected to the DOS network keeps the 100.100.110.100 address it already has. The second interface in your client PC, connected to the Sun server, can get IP address 100.100.110.201.

The internal routing table of the OS on your Client computer should now select the correct interface depending on the destination IP address. Additionally no packets for the "other" network will be seen on the networks (no chance of collisions).

zakirhussain
May 5th, 2008, 01:08 AM
Thanks a lot for providing workable solutuion. It worked as expected. Thanks