Hello every one ...

I need help to make connection between two PC through socket programming ...
in which scenario i want connection is as below ...

there are two networks on different places.One network having internet connection of COM1company and through that one connection only other PCs are getting internet and each PC in network havin their own local network ip address like 192.168.1.1 etc...


now in second network also same scenario is there.

think that first network internet conection having ip of 200.200.200.5 and second network's internet connection having ip 200.200.400.10

now i want to make connection between first PC of first network and first pc of second network.think that their ip's are same 192.168.1.10 but network is different.

if i m trying to connect to first network via 200.200.200.5 ip than it not allowing me to make connection.

than wht's the way to make connection ..
any help please ............

Recommended Answers

All 9 Replies

In short i wanted to know that i want to
connect to specific computer on LAN from outside of lan
through C# coding ....

the trick is that you have to set up a forwarded port on the router to the network that will be connected to.

example, if network A has an external IP (the IP that the internet sees) of 168.100.159.172 and it supplies internal IPs (lan) incremented based on 192.168.1.100 Then that router needs to be configured to forward the port your application uses to the computer on the local network that is running the server application.

then the client is just told to connect to the external IP of the network the server is on in this example 168.100.159.172 at which ever port is forwarded for the app.

If you don't have access theses settings your only option is to use a 3rd system somewhere on the net as a server that will relay the information.

thnks for your reply ...

one more quetion is here ....

see,
if my server is on external ip like u say 168.100.158.200. okay ...
now i try to connect to that server from a PC which is internal PC of a lan network and having internal ip ( local ip ).

here if i want to made connection to server and want to send message to server from my client than it can be done as server is on external ip so no issue regarding port.

but if i want to send message back to that client than whether i want to configure router or it will simply done??

and ya i am not having right to access any setting of router coz i want to make my socket application to run on internet..... i mean anybody from anywhere should access that application.

so how could i make these types of connection ...

please give some advise ..
i really want it coz it's my college project and my submission date is to nearrrr...

once connected, the tcpClient object holds a reference to the client connection, so you use that object to send and receive data. you never worry about the IP or routing of the client.

Did your college programming instructors not do a very good job of explaining it?

hahahahahaha ...

Actually i m creating remote desktop application ...
as in local networks i m not directly able to communicate with remote objects, so i m thinking to do it via socket and web server.

r u having any sort of knowledge regarding this ??

i mean , is there any way to access remote object in local network from out side that local network or i have to go through sockets??

please reply... waiting for your reply..

...Sockets are basically how the internet works, and how you connect to a computer on a "local" network from the outside world is by configuring the router that controls the flow of information on the "local" network to forward a port to a particular device. That's pretty much the only way its done. So I'm not really understanding your problem.

lets say you are in a internet cafe. all the computers there are on a network to share the internet. now the Router that routes the information between them and the internet assigns all the computers there a "local" address, 192.168.1.100, 192.168.1.101, 192.168.1.103 This allow the router to know who's who. but no matter what computer on that network sends out a request, the internet sees it coming from the address that the router revcieved from the ISP's routing system. that's the external IP. now in order for your program to be connected to by the outside, the local router has to be configured to redirect all the data passed on a particular port to a local address. if your app is on 192.168.1.101 on the local network then the port you use on that program needs to be set to be forwarded by the router to 192.168.1.101

Now if you use a webserver that is directly connected to the internet, not on a local network. you can connect to that more easily, then use a program on that computer to relay data between all the clients, that is the typical way. But using a remote desktop system like that can be a security issues so be careful.

okay, now i m getting some things ...

i have done a lot googling for getting solution about this ....

one solution i found was create VPN between that 2 computer in between which you want to make connection.

do u know anything about VPN or how can i achieve this through my C#.net 2005.

and as u saying that port of the router should be forwarded to that PC on which i want to make connection. can i do this through code or i have to contact to ISP. in case of contacting ISP to do this i cant contact each and every ISP to run my application on any other PC.

if u r having any alter native way or any way from this two way and that can i achieve through code than please inform me ....

thnks for this many help ...

Sorry, VPN is a safe way to transmit data, but I don't know much about it. and no you can't forward ports through code, but you don't have to worry about the ISP, just the router that is responsible for your LAN. if you check your internet connection on one of those PCs and get the "gateway IP" enter the gateway IP into a browser and you will be prompted for the password to the router, just go to PortForward.com. It will give you step by step instructions on forwarding ports on hundreds of routers.

thnks a lot ...

i will try

hope i'll get success ...

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.