personal program through a vpn like hamachi or open vpn? - c

I'm making a simple game than uses udp or tcp sockets to connect in c.
I've gotten vpn set up before and used the default vpn chats.
I'm just wondering how do I make my program work?
What port do I use? How do I make connect through the vpn?
I know just typing in the vpn address doesn't work.

Well, all of this should depend on how you have things set up. The VPN software will connect to each other using the ports and hostnames or IPs you have designated.
The game you say you are designing: is this supposed to be a two person thing, so they will have to talk? In that case, you specific whatever port you desire in the code when you are making it.
Hope this is what you are looking for :-)

Related

which IP to use to connect to two different computers using telnet C

I have two laptops, both running Ubuntu.
I want to write a chat server in C, which can talk to my other laptop and receive messages back from it.
I know that when the client and server programs are both in a single machine, I can use local host (127.0.0.1) and make them talk using telnet but what about connecting two different computers (which are on the same network)? Which IP and port should I use for them?
A is the Server with IP[A] address (ex: 192.168.1.2)
B is the Client with IP[B] address
So on your chat Server on A at some point in the code you will open a port, you will specify a port number to open. If the number of the port is X then on the client you will connect to IP[A]:X
To give you an example with X=4444, you will open a connection like: 192.168.1.2:4444
Regards,
Basically all that you need to make sure as far as a port goes is that the port is not already in use by another service. There is a number a ways to do this, but I suggest you start by looking at commonly used ports.
As far as IP goes, you are going to want to determine if you want to use the public or private IP of the machines that you are attempting to connect. If you are using the public IPs you will probably have to set up port forwarding in some capacity. If you are just connecting two private ips (i.e. the one the same network) then you don't need to port forward.
Ultimately, this issue is highly specific to you use case and we would need more information to answer it for your exact case.

What port(s) can I use for a messenger application

Please forgive me for being naive on the subject, however, I do not understand ports and how they work in the slightest. I am trying to make a program where two computers could communicate given their IP addresses and I am using TCP protocol. I don't, however, know what port(s) I would be able to use for this application, because when I look up TCP ports I get a list of ports each with their own function. Any help is useful.
P.S. I am using C to create my program
The short answer is you can choose any port you like - although the safe range is generally considered to be between 1024 and 65535. The only problem that you will encounter is when some other program installed on the device is already listening on that port. Unfortunately, there is no port that is guaranteed to be available to listen on.
One possible solution to this is to have a primary listening port and a fallback secondary port. You can then first try to connect on the primary port and, if a satisfactory response is not received, try to connect on the secondary port. However, even this is not infallible, as there is a chance that the secondary post could also be in use.
The easiest approach is to try to create your listener on the port that you have chosen, and if the port fails to create, let the user know that some other application is preventing execution of your application.

How to run Client-Server on different computers using Sockets in C

I am able to run a client and server on the same computer on two different terminals in Linux. Now I want to run the same model on two different computers. I am guessing there is more to this than just changing the IP address and the port number to that of the Server.
Any guidance on the matter is highly appreciated.
Thanks.
Make sure the port is forwarded in your router and exceptions for the port is added to the firewall. Then you should be ready to go!
If you have the computers in the same network you can do it without forwarding your port.

How can i connect to my friend through internet with sockets?

I've written the game on C with sockets which perfectly works on LAN, but how can i connect to my friend through internet? Our ip addr. are dynamic, but even so (i can recompile program with current values and give him it), what should i enter? hostname gives 127.0.0.1 or 192.168.., both are correct and absolutely logical, can someone help me and say any method for connecting each other?
P.S. UNIX platform;
First off the IP you're looking for is your public IP. To find it, simply google "what's my ip" from both locations, and that'll give you the two IPs. Second you'll need to configure your routers to perform port forwarding.

Faking a network communication to test client/server on one computer

I have a course project where I'm suppose to present some networking stuff. There are great chances that I have to do it on one computer. So my question is, how do I show a communication between tcp/ip or tcp/udp? I'm not a networking expert, I understand the concept of sending data which is red. And I think I need two IP addresses.
You don't need two IP addresses. Just start the server on the machine, and have the client connect to address 127.0.0.1 and the appropriate port. (This address always refers to the same machine the program is running on.)
You can run a virtual machine on your computer and work on network between them.

Resources