Server connection to client behind NAT [closed] - c#

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I've made a server/client application in C#.
My question is the following: Let's say a client is behind an NAT (Like a router) and tries to connect to a server. From the server's perspective, the server only knows the client's external IP address. How do you determine exactly which computer to send the packets to that is behind an NAT? I understand port forwarding from the router on the client's end is a common way of solving these type of problems but if you look at applications like Skype, port forwarding is not necessary to properly establish a connection between the server and however many clients behind the NAT. This question can be asked vice-versa as well (I.E: client to server behind NAT).
I'm pretty new at socket programming so I'd love to hear any guidelines or materials that I can read over to fully understand this stuff.

You shouldn't worry about NAT in the application layer. If you receive a message with an IP say 200.51.255.79 you can send the answer to the same IP. Routers will handle the NAT and further routing automatically. It's not like this with port forwarding of course but it is with NAT.
Skype works in a very interesting way to get around port forwarding and firewalls using a server sided database of current ips and ports where each user is waiting for a response. You should look that up on the internet for a full explanation. It's a really good read =).

Related

Send a open port request to router [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am creating a peer to peer application in c sharp, I was wondering if it was possible to send a request to the other persons router over the internet and ask it to open port 1234, or if there is any other way of uploading and sending data without port forwarding, or even an application that i can port forward my router via command line or dll would be great. Please help me for this is making me frustrated.
There is no way for an outside app to tell a router to open a port to one of its local machines. This would be a huge security hole.
If a local machine wants access from outside, it could use UPnP (NAT Traversal) to tell the router to forward a port to it (or you could simply configure your router to forward the port).
If both peers are behind NAT with no access to port forwarding, you would have to use some 3rd party server that proxies the data.

What is the right programing model for global chat app? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I am trying to build a chat app in c# that would work in the wan network.
There are 2 side in the app. Server side and client side.
In my thoughts i think that every message from client to client need to be passed to the server and the server will forward it to the right des client. The communications between the clients wont be directelly.
Is this the right model?
If yes, does the server need to have one socket that will listen to all clients? (Because every client sends his message to the same port at server).
Will the sever can handle management of million of messages on same port?
I think it is really up to what you want to accomplish, each choice has it's own pros and cons.
For example:
Using a centralized server can track messages , which users are online etc... but you will have to manage the ports for each connection (see explanation at the end of the answer for details).
Using a P2P model, you will not have the bottle neck and management required by the centralized server, but again it might be more of a hassle to manage a non centralized system (depends what exactly you want to accomplish).
If you are going to the centralized design, Typically You would have a server with a port that will listen for requests.
once a user wants to connect, the server will start a new thread for the client, and will assign a port for him (the thread will be typically from a thread pool and the port from a specific port range).
this will allow users to speak to the server in a non-blocking manner, and by that allow for multiple users to use the service simultaneously.
Take a look at SignalR and the chat system implemented using SignalR, Jabbr:
http://signalr.net/
http://about.jabbr.net/

How to send Audio/Video over internet to multiple clients? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I have designed a virtual classroom software for students with disabilities, it is being used by some local colleges. The limitation of the software is that the students within a Local Area Network (LAN) are able to connect with server in order to receive audio/video data. I have used sockets to connect clients with server. Now the demand for the software has increased and students outside of the LAN want to connect to server using their internet connection. I am aware that I have to rewrite the server/client connectivity modules, but I am not sure how to go about connecting clients to server using internet.
I think one way is to use a vpn but I am not really sure.
Any guidance would be much appreciated. Thanks in advance.
1)First, the good news: You may not have to rewrite your client server code (at least not completely)
2)This question may be better suited for serverfault
3)Get with your IT staff to discuss your needs. Developing the app without consulting them is asking for trouble, because they're going to be the ones to ensure the proper firewall ports are opened. Even if you had a VPN, without consulting them there's no guarantee it would even work. Because you would need
4)A routable IP address. Yes, DYNDNS or something similar would work, but that introduces another single point of failure. No IT staff? Then
5)Find an IT consultant knowledgeable in basic networking, or make heavy use of serverfault.

TCP between C# and C++ [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I'm creating a server that will in most/all cases be run on the same machine as the client. The client will need to be able to send and receive messages from this server. Some of the received messages will not be answers to questions (such as with http requests). All the messages will hold is a string that the project then uses to determine what function needs to be run.
The question is "Do I need to connect on two ports: one for sending and one for receiving?" If I use tcplistener with C# and C++ POSIX for networking, can I just send and receive messages on the same port?
Yes. You can send and receive on the same port and that's the intended way to communicate with tcp.
EDIT
You have two actors, a host and a client.
The host... will open a local network port (that you specify) and listen for new connections and communications from clients.
The client... can (and probably should) choose it's own local port and connect to the host on the port you specified.
Both the host and client... can communicate over the established connection. The host can send data to the client as long as the client is listening.
Have the server bind to and listen on a well-known port. Have the client bind to any port (you can let bind pick for you) and connect to the server on its port. Exchange messages.
Yeah, there isn't a difference between tcp/ip.

Send Message to remote PC in local network [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
How can I in c# send Message box to remote computer? I have credentials of remote PC and know PC name. Can use for this purpose WMI?
Look into the NET SEND command. However, the messenger service needs to be enabled on the remote computer - you could use PSEXEC to start this.
I think you're asking how to send a message to a remote computer via c#. If so, you have several options see below:
Microsoft message queuing - Only if you need a super robust framework that gauarantees delivery of your message even if destination goes offline.
UDP multicast message - You can use the System.NET.Sockets namespace to send UDP packets and build a client to listen for them which can be run of n number of remote server. This is not error checking and if the remote server is not up then you are out of luck.
TCP socket connection - You can use the System.NET.Sockets namespace to send TCP packets and build a client to listen for them which can be run of n number of remote server. This is error checking and if the remote server is not up then you are out of luck.
Hope this gives you some direction.
Enjoy!

Categories