
03-30-2004, 08:52 PM
|
 |
Contributor
|
|
Join Date: Feb 2004
Location: Melbourne, Australia
Posts: 633
|
|
*Solved* Get local IP from LocalEndPoint
|
Heya,
In my VB6 app I had: my_ip = Winsock1.LocalIP
Now I need the .Net equivalent to this. I have fixed all my other Winsock API stuff would you believe, but I can't work out this simple problem!! hahaha
I have searched MSDN, and adapted what they had to get the following, but it doesnt work. I think maybe because the socket isnt connected?? But I only want the local IP. There must be an easier way.
Code:
Dim tcpSocket As New Net.Sockets.Socket(Net.Sockets.AddressFamily.InterNetwork, Net.Sockets.SocketType.Stream, Net.Sockets.ProtocolType.Tcp)
MsgBox(Net.IPAddress.Parse(CType(tcpSocket.LocalEndPoint, Net.IPEndPoint).Address.ToString()))
|
Last edited by sgt_pinky; 03-30-2004 at 09:15 PM.
|