Windows Sockets and PC's with 2 network cards 
Author Message
 Windows Sockets and PC's with 2 network cards

Hello,

I have been working on a network project. We have come up against a problem
when a server PC has 2 network cards. We're using UDP Datagram Sockets, as
our software uses Multicast IP addresses. The problem is that when
initialising a socket, it may bind itself to either of the network cards.

As far as I know the following function should work....

*  m_Socket = socket(PF_INET, SOCK_DGRAM, 0);

This creates our datagram socket....

  if (m_Socket == INVALID_SOCKET)
  {
   rgeStatus = WSAGetLastError();
   strTmp.Format("Error %d creating socket on port %d", rgeStatus,
m_iLocalPort);
   LOG_ERROR(strTmp);
  }

*  // Bind to local port if successful
*  if (rgeStatus == G_ERROR_OK)
*  {
*   // Set up address structure
*   m_sLocal.sin_family = AF_INET;
*   m_sLocal.sin_addr.s_addr = INADDR_ANY;

The szLocalIP string holds a normal IP address (passed to the function from
where this code has been extracted).

*      if( strcmp(szLocalIP,"NULL") )
*      {
*        // If the registry setting on this client PC is set then use this
address for binding
*        // the socket
*        m_sLocal.sin_addr.s_addr = inet_addr((char *)szLocalIP);
.....etc,etc

Its my understanding that the above line forces the socket to bind itself to
the address held in the szLocalIP string??? Have I missed something????

Can anybody help?


Thanks in advance,

Nick Lewis.



Fri, 04 Jan 2002 03:00:00 GMT  
 Windows Sockets and PC's with 2 network cards
Despite the long list, none of the relevant newsgroups got included
in the distribution. I cannot imagine this socket stuff has anything to do
with 3rd party, ATL, database, de{*filter*} etc. The post is as good as
a SPAM.


Quote:
>Hello,

>I have been working on a network project. We have come up against a problem
>when a server PC has 2 network cards. We're using UDP Datagram Sockets, as
>our software uses Multicast IP addresses. The problem is that when
>initialising a socket, it may bind itself to either of the network cards.

>As far as I know the following function should work....

>*  m_Socket = socket(PF_INET, SOCK_DGRAM, 0);

>This creates our datagram socket....

>  if (m_Socket == INVALID_SOCKET)
>  {
>   rgeStatus = WSAGetLastError();
>   strTmp.Format("Error %d creating socket on port %d", rgeStatus,
>m_iLocalPort);
>   LOG_ERROR(strTmp);
>  }

>*  // Bind to local port if successful
>*  if (rgeStatus == G_ERROR_OK)
>*  {
>*   // Set up address structure
>*   m_sLocal.sin_family = AF_INET;
>*   m_sLocal.sin_addr.s_addr = INADDR_ANY;

>The szLocalIP string holds a normal IP address (passed to the function from
>where this code has been extracted).

>*      if( strcmp(szLocalIP,"NULL") )
>*      {
>*        // If the registry setting on this client PC is set then use this
>address for binding
>*        // the socket
>*        m_sLocal.sin_addr.s_addr = inet_addr((char *)szLocalIP);
>.....etc,etc

>Its my understanding that the above line forces the socket to bind itself
to
>the address held in the szLocalIP string??? Have I missed something????

>Can anybody help?


>Thanks in advance,

>Nick Lewis.



Sat, 05 Jan 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Windows Sockets and PC's with 2 network cards

2. Pocket PC and network cards: the next step...

3. Pocket PC and network cards.

4. PC Card - 2 windows?

5. ActiveSync over 802.11b card, conflict with onboard network card

6. Finding Network PC's

7. Windows Sockets Network Programming

8. Windows Sockets on Pocket PC

9. New article at Pocket PC Developer Network - Testing programs on Pocket PC

10. PC Port Access in Windows' Protected Mode

11. Who's on the network (Windows 95)

12. help about the windows' socket console app

 

 
Powered by phpBB® Forum Software