Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to bind to specific nic for udp send

Status
Not open for further replies.

gkmccone

Technical User
Oct 24, 2001
17
US
I have a mahine that has two nic cards in it that sit on two different LANs. I am trying to send upd messages to one
of the LANs but not the other. I am using the following code fragment to create the socket.

$self->{udpSocket} =
IO::Socket::INET->new( Proto => 'udp',
PeerAddr => $self->{Address},
PeerPort => $self->{Port},
LocalAddr=> $self->{Bind},
);


where $self->{Bind} is the nic that I wish to send the upd message on. What I am see when i send data on the socket is not what I want. It appears that the send is leaving on the last card listed by ipconfig, which is not the card I want.

I have even tried
$self->{udpSocket}->bind( $self->{Bind} ) after creating the socket without any luck.

I am using perl 5.6.1 build630 from Activestate on a Windows 2000 machine.

Thank you for any help
 
What is the exact value stored in [/tt]$self->{Bind}[/tt]?

"As soon as we started programming, we found to our surprise that it wasn't as
easy to get programs right as we had thought. Debugging had to be discovered.
I can remember the exact instant when I realized that a large part of my life
from then on was going to be spent in finding mistakes in my own programs."
--Maurice Wilk
 
I am starting with the simplest case, $self->{Bind} has the four octet ipaddress assigned to the card as a string value, i.e. XXX.XXX.XXX.XXX. I am passing it a string since the IO::Socket::INET module passes it through pack_sockaddr_in before passing it up to IO::Socket::bind
 
Hmmm. I've got ActiveState on NT boxes and XP boxes (I'm suspecting MicroShaft rather than ActiveState) so if you'd like me to run any test code for you I'd be happy to report on the results.

Cheers,

"As soon as we started programming, we found to our surprise that it wasn't as
easy to get programs right as we had thought. Debugging had to be discovered.
I can remember the exact instant when I realized that a large part of my life
from then on was going to be spent in finding mistakes in my own programs."
--Maurice Wilk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top