HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Programmatically or environmentally selecting Netw...
Operating System - HP-UX
1834178
Members
2092
Online
110064
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2006 10:32 AM
09-01-2006 10:32 AM
Having problem finding any information on how to either programmatically or environmentally set the network interface a process uses. My need is to have a client application network request's look like they are comming from distinct IP's depending on certain criteria.
Thanks,
R.
Thanks,
R.
Solved! Go to Solution.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2006 07:30 PM
09-01-2006 07:30 PM
Solution
I assume you mean the client application is running on a host that has several IP addresses (either interfaces to different physical networks or more likely IP aliases) and you want to pick just one of them. Am I correct?
When setting up a network socket for incoming connections, you normally do a set of system calls: socket() to create the socket, bind() to select a port, listen() to wait for connections and ultimately accept() to receive the incoming connection. With outgoing connections, it is normal to just create the socket and use connect() to set up the connection.
It is possible to use the bind() system call in the outgoing case too. It is not done very often, because usually the client software does not care which local address and/or local port number it will get. If bind() is not used before connect(), the operating system will allocate a free port.
The bind() system call will require a sockaddr_in structure as input. It should contain both the desired local IP address and local port number. To select the IP address but allow the OS to pick the local port number, just set the port number (sin_port) to zero. See "man 2 bind".
If an application has the option to make it bind() its outgoing connections to a specific IP address, it is very useful when packaging the application for use with ServiceGuard.
When setting up a network socket for incoming connections, you normally do a set of system calls: socket() to create the socket, bind() to select a port, listen() to wait for connections and ultimately accept() to receive the incoming connection. With outgoing connections, it is normal to just create the socket and use connect() to set up the connection.
It is possible to use the bind() system call in the outgoing case too. It is not done very often, because usually the client software does not care which local address and/or local port number it will get. If bind() is not used before connect(), the operating system will allocate a free port.
The bind() system call will require a sockaddr_in structure as input. It should contain both the desired local IP address and local port number. To select the IP address but allow the OS to pick the local port number, just set the port number (sin_port) to zero. See "man 2 bind".
If an application has the option to make it bind() its outgoing connections to a specific IP address, it is very useful when packaging the application for use with ServiceGuard.
MK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2006 02:31 AM
09-05-2006 02:31 AM
Re: Programmatically or environmentally selecting Network IFace
Thanks for the response - it answers my question precisely. Will give it a try.
R.
R.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP