Finding Client IP

Rephistorch

Member
Joined
Oct 4, 2005
Messages
16
Programming Experience
3-5
Finding Client IP [resolved]

Sorry if this is in the wrong part of the forums, but I couldn't seem to find the right one for this particular case. So, I'm making a windows form to be a server for a chat program I'm making (internet chat). I'm creating a client, and the client knows which IP address to connect to, but I can't seem to find a way to get the IP address of the client so that my server can send data back to the client. Any help is appreciated

-Rephistorch
 
Last edited:
I'm sorry I forgot to say that I was using visual basic .net 2005. It seems that in this version the only things in system.web are ASP functions. If anyone knows of another way that would work for 2005 express please tell me. EDIT: I checked the web developer and the http thing is there. However it is not there in visual basic.
 
Last edited:
try this
VB.NET:
[FONT=Courier New][COLOR=#009900]'Get the hostname  [/COLOR][/FONT]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] myHost [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2] = System.Net.Dns.GetHostName()[/SIZE]
 
[SIZE=2][FONT=Courier New][COLOR=#009900]'Get the IP from the host name[/COLOR][/FONT]
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] myIP [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2] = System.Net.Dns.GetHostEntry(myHost).AddressList(0).ToString()[/SIZE]
 
[SIZE=2][FONT=Courier New][COLOR=#009900]'Show the IP[/COLOR][/FONT]
Label1.Text = myHost & ControlChars.NewLine & myIP
[/SIZE]

i suppose client should send its IP address to the server before server is able to looking for any IP address ... right?

Regards ;)
 
I think visual basic hates me :p. At any rate, it seems that what you said would work, as long as your not behind a router (which I am, and almost all of the people I want to send this to are :eek:). When you're behind a router it sends your local IP like 10.40.0.100. I wonder what would happen if you tried to find the address of the router itself...

Well I'm off to work... and then trying to figure this out. If you have any more suggestions, feel free to telepathically give me the answers, :D
 
Note: In the express versions of vb.net and C# there is only a small sub-set of functionality available. If your doing this for a business then maybe you would be able to get the functionality needed in either the standard edition or the professional edition of vb.net.
 
I know there's like professional or enterprise edition of visual basic, but it's not for a bussiness. And hey, express is free (the main reason i got it). Since this is just for my entertainment and learning purposes it doesn't make sense to buy it (at least not at this point in time).
 
lol. Apparently i dont need to connect to the client afterall... :rolleyes:
I just thought i had to. Well, to make it short i didn't know that you could both read and write to the same stream without screwing everything up. Well that clears up what i had intended on doing with this program so, I guess this is solved. Thanks for all the input.
 
Back
Top