473,387 Members | 1,485 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Socket and local IP address

Hi,

When we create a new socket and make it connect to a remote endpoint,
how can we tell to the socket to use a specific IP address on the local
computer, when multiples IPs are enabled.

Thank you
Marty
Nov 21 '05 #1
2 1465
In article <1dHle.12842$HI.10279@edtnps84>, Marty wrote:
Hi,

When we create a new socket and make it connect to a remote endpoint,
how can we tell to the socket to use a specific IP address on the local
computer, when multiples IPs are enabled.

Thank you
Marty


Use the sockets bind method befor you call Connect.

mySocket.Bind (New IPEndPoint (MyIPAddress, 0))
mySocket.Connect (.....)

The 0 for the port lets the network service provider assign the local
port - but if you want the local endpoint to have a specific port as
well as IP, then you can specify it there...

--
Tom Shelton [MVP]
Nov 21 '05 #2
Thanks Tom :)
Marty

Tom Shelton wrote:
In article <1dHle.12842$HI.10279@edtnps84>, Marty wrote:
Hi,

When we create a new socket and make it connect to a remote endpoint,
how can we tell to the socket to use a specific IP address on the local
computer, when multiples IPs are enabled.

Thank you
Marty

Use the sockets bind method befor you call Connect.

mySocket.Bind (New IPEndPoint (MyIPAddress, 0))
mySocket.Connect (.....)

The 0 for the port lets the network service provider assign the local
port - but if you want the local endpoint to have a specific port as
well as IP, then you can specify it there...

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: crypto_stonelock | last post by:
Hello, I was wondering if anybody knew how to retrieve the IP address attributed dynamically by your ISP without having to use the info collected on a socket with say .getLocalAddress. I'm...
21
by: Alexander N. Spitzer | last post by:
If I have a machine with 3 virtual IP addresses (192.168.1.), how can I start 3 instances of the same RMI application (each started with different properties/configs), each listening on the port...
2
by: Sherif ElMetainy | last post by:
Hello I am writing a HTTP client, that will run on a computer with multiple IP addresses. I want to bind the TCP socket for the HTTP connection to a specific IP address, but unfortunately there...
0
by: Gregory Hassett | last post by:
Hello, I want to periodically send a TCP packet to a peer, always from the same source port. That is, each packet will come from my local ip address, port 8801, and go to the peer's ip address,...
3
by: alex tomlinsom | last post by:
I've got a c# socket that is open and listening to incoming UDP packets on a port. When the packet comes in, I want to figure out what address it came from. The problem seems to be that while the...
13
by: Sandeep Singh | last post by:
I am making socket client application in C# how can i get ip address of client who has connected to server
8
by: Mark Fink | last post by:
I try to port a server application to Jython. At the moment I use Jython21\Lib\socket.py Currently I do face problems with casting the string "localhost" to the desired value:...
11
by: weird0 | last post by:
I am a beginner to socket programming to in c#. I know the concepts as to how to program them. I get the above exception when i tried writing the code for the server side on the line...
5
by: natambu | last post by:
I have a linux box with multiple ip addresses. I want to make my python client connect from one of the ip addresses. Here is my code, no matter what valid information I put in the bind it always...
2
by: bobido | last post by:
Hi there, In C# i would like to listen to the following socket: Local Address: 0.0.0.0 Local Port: 1498 Remote Adress: 127.0.0.1 Remote Port: 40001 Protocol: UDP
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.