I have a *IX system with 2 NICs. I have a program that allows me to make a connection to an outside IP address using a socket. This works great except I need to bind to one of my local NICs so that I can go out over the VPN. For example: I have 192.168.199.100 and 200.172.15.40 as my IP addresses for the NICs. The VPN connections ALL use the 192.168.199.100 address but the *IX system will grab whichever NIC is not busy and most of the time it is the 200.172.15.40 address and I can not make a connection to the other side using that address. Without re-writing the code to use more update to date modules does anyone know of a way to get "use Socket"; to bind to a LOCAL IP address. Below is my "connecting" code that the program currently uses.
$them = $opt_h; $iaddr = inet_aton($remote); $paddr = sockaddr_in($port, $iaddr); $proto = getprotobyname('tcp'); socket(SOCKET, AF_INET, SOCK_STREAM, $proto) || die "socket error: + $!"; print STDOUT "connecting...\n\n"; if (connect(SOCKET,$paddr)) { print STDOUT "Connected to host: $them, port: $port\n\n"; } else { die "socket error: $!"; }

In reply to bind a client connection by lindseyprog

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.