473,398 Members | 2,120 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,398 software developers and data experts.

Get specific Inerface / IP from a Remte IP

rlc
I am using a toolkit, part of which creates TCP/IP connections using a
function 'Connect(<local IP>,<local Port>,<Remote IP>,<Remote Port>)'. This
function's signiture looks very similar to the Socket object signiture. If
you pass a blank local IP it will get the IP for the DEFAULT interface, which
is not always the desired IP. How can I get the specific Local IP from a
Remote IP?

EX:

Interface 1: 10.1.1.1
Interface 2: 192.168.1.1

..Connect("",0,"10.1.1.2",104)
Sets local ip to 10.1.1.1

..Connect("",0,"192.168.1.2",104)
Sets local ip to 10.1.1.1

I would like to pass the Local IP form the remote IP instead of the blank
string. Any help would be great!

~rlc
Nov 21 '05 #1
1 1417
rlc
Well here is my solution, hopefully I can have them update the toolkit to
avoid extra connections....

Dim l_Socket As System.Net.Sockets.Socket
Dim l_RemoteIP As System.Net.IPAddress
Dim l_RemoteEP As System.Net.IPEndPoint
Dim l_LocalEP As System.Net.IPEndPoint
Dim l_LocalIP As String

Try

l_RemoteIP = System.Net.IPAddress.Parse(txtRemoteIP.Text)
l_RemoteEP = New System.Net.IPEndPoint(l_RemoteIP, 104)
l_Socket = New
System.Net.Sockets.Socket(Sockets.AddressFamily.In terNetwork,
Sockets.SocketType.Stream, Sockets.ProtocolType.Tcp)
l_Socket.Connect(l_RemoteEP)

l_LocalEP = l_Socket.LocalEndPoint

'get the local IP
l_LocalIP = l_LocalEP.Address.ToString
Catch ex As Exception
'failed to connect do something here

Finally
If l_Socket.Connected Then
l_Socket.Close()
End If
End Try
Nov 21 '05 #2

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

Similar topics

6
by: Franz Steinhaeusler | last post by:
Hello, with following function, i get a human readable date/time format. mtime = time.strftime(self.timeformat ,time.localtime(st.st_mtime)) However is there a simple solution to get a...
2
by: Brett Gerhardi | last post by:
Hi all, I'm trying to something that I'm sure must be possible within the schema language but I cannot seem to work it out. Briefly, I am defining a multi-tiered base structure - each tier has...
6
by: Mark Cunningham | last post by:
I am curious if there is something that would be considered a proper method for locating small (three to four items) amounts of page specific styling. Or does it really matter in the great scheme...
0
by: Steven Kelly | last post by:
For those going to XP 2005 (Sheffield, UK, June 18-23) and interested in modeling, the following workshop may be of interest: Agile Development with Domain Specific Languages Scaling up Agile -...
3
by: ExclusiveResorts | last post by:
Can the CallContext be used reliably for storing request specific data? We are developing an application library that uses the CallContext to keep an IdentityMap (hashtable of business objects...
4
by: Nalaka | last post by:
Hi, I have some request specific data that gets created in a "early event", that I need to pass around to many other events. I need access to this data during that request. (and more importantly...
2
by: cemlouis | last post by:
Hi, I want to show some specific pages to people that comes to my site from specific urls, I know the variable $_SERVER will be used but how? For ex if the visitor comes from a site that is...
2
by: Gabriele Farina | last post by:
Hi, I'm tring to implement a Singleton object that should be specific for every thread who create it, not global. I tried a solution that seems to work, but I have a very poor knowledge of...
4
by: Pool | last post by:
I tried to connect DB2 (Sitting in Unix server at my client location) using Db2 connect V8. I am getting the following error message. I tried all the possible options BUt the error is same.. See each...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.