+1 to Scott's answer. Now to elaborate - if both IP addresses are on the same subnet, add a route to the destination specifying the correct local address for the connection. It doesn't make sense to hardcode an IP address in a program.
Actually, I guess it doesn't matter if they're on the same subnet. Routing rules still apply. I just figured it was likely you had multiple addresses on the same subnet like I do. I might just add another +1 to Scott's answer for that :)
--
Sean Porterfield
________________________________________
From: rpg400-l-bounces@xxxxxxxxxxxx [rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Scott Klement [rpg400-l@xxxxxxxxxxxxxxxx]
Sent: Tuesday, September 29, 2009 22:37
To: RPG programming on the IBM i / System i
Subject: Re: IP address used by Sockets
The bind() API can be used to force a TCP socket to use a particular IP
address, as Michael already explained. Set the port to 0 to let the OS
choose the port.
However, this doesn't make sense to do. IF your TCP/IP routes are
configured properly, it will automatically pick the correct IP address.
If the routes aren't configured properly, binding to a particular
address won't help you, because the packets still need to be routed
correctly for the connection to work.
So this doesn't make a lot of sense to me.
Binding to a particular IP address is a tool usually used on a listening
server program so that you can (for example) listen on your internal
subnet without allowing access from the public internet. Stuff like
that. It doesn't make sense to use in a client program -- at least not
in my experience.
I wonder if you don't have a misconfigured route somewhere?
Joe Wells wrote:
Our 400 has two IP addresses.
Using Scott Klement's socket utilities service program, I have created
working client and server programs.
Here is my dilemma - our network folks established a secure connection
(tunnel?) between us and another system. The problem is that the one of my
socket programs is now using the "other" ip address on our 400.
Consequently, this program cannot connect!
So, my question is - Is there a way to specify the outbound IP address the
socket uses?
Thanks,
Joe
Joe Wells
University of Alabama Health Services Foundation
500 22nd Street South, Suite 308
Birmingham, AL 35233
205-731-5610
This email is confidential, intended only for the named recipient(s) above and may contain information that is privileged. If you have received this message in error or are not the named recipient(s), please notify the sender immediately and delete this email message from your computer as any and all unauthorized distribution or use of this message is strictly prohibited. Thank you.
As an Amazon Associate we earn from qualifying purchases.