sgt_pinky
03-30-2004, 08:52 PM
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.
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()))
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.
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()))