hi,
I am recently very curious to know how I can make a connection between two computers which are not in a local network.
I googled a lot but there are always solutions for local IPs
Now I know that I should make a server and a client to send and recieve ,
but the problem is global IP

Is there anybody to give me a solution ?

Thank you ;)

thank you,
but all of them work through local IPs as I said

I found that I should use socket programming and there is a sample from microsoft

http://code.msdn.microsoft.com/VBSocketCommunication-f1fb4541

I worked on it a lot to make it through internet
but the main problem is remained which is I cannot connect to a global IP :S
Can anybody help me make this work through global IP

nobody here to help ?

By Global Ip, you mean your external IP, or the IP that is visible on the outside of a router connection? You cannot retrieve your external IP through a .NET class. You will have to depend on external services. WhatsMyIP.org is a good service you can Parse the HTML from the result. To do that just search the text with RegEx for the format of the IP. The IP will be at the top of the page, so the first hit is all you need. Applications such as BitTorrent and LimeWire use services like these.

I know how to get my external IP
but how can I get connected to that IP
let me say in other way ,
I want to be able to send a message to my friend that is not in local network
I tried many ways :
tcplistener , sockets and anything you can imagine about sending and recieving
but I could never do it through internet
I think it must use something else instead
you said
> You will have to depend on external services
that means I cant make an app to do that ? :(

You will never want to connect to your own exteral IP (honestly, I don't think it's possible). To communicate through the web. You will have to have two client/server interfaces. One for initiating the connection, one for receiving the connection request.

First you need a server socket initilized and open, this will be listening for an incomming connection request. More Info on MSDN.

Next, you have a client that is outside of the the network that attempts to conect to your external IP address. More info on synchronous and asynchronous sockets.

Remember, you may need to have to foward your ports to allow the connection through the router, and you will have to allow the firewall to allow the application.

thanks a lot Maligui,
I think I have tried those you said and I think my problem could be port forwarding then
if I could find guideness for this that would be good
you dont know anything about forwarding port ?
I think it's very more difficult than what I think, yeah?

Yes, since each routing manufacturer has a different setup for port fowarding. I would use this site for a guide.

http://portforward.com/

There is no need to worry about the port from the router to the computer, that is what routers do, they will always be different then the port you are connecting to from the outside. All that matters, is that you connect to the open external port.

You can also set up port tiggers, where when an outgoing port opens, it triggeres another port to open. That port you will use for incomming connections.

that was a very useful information I would have got
Now I know what I am looking for
So it cannot be programmed
I really appreciate your help , thanks a lot :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.