Recent

Author Topic: [SOLVED, THANKS FOR HELP] Port Forwarding Help  (Read 10559 times)

Jishaxe

  • Full Member
  • ***
  • Posts: 103
  • Hobbist Programmer
[SOLVED, THANKS FOR HELP] Port Forwarding Help
« on: June 27, 2010, 02:22:51 pm »
Hello people. I need help, please.
I am building a pair of applications, one the server to go on my computer, and the client to go on a friends computer, which is far away from where I live. The client is designed to connect and send data over the Internet to my computer, but I need to set up port forwarding on my router.
The question is:

How exactly do I set up port fowarding on my router JUST for sockets on applications? I looked at www.portforward.com but they only have instructions for games. Any help and/or links would be appreciated.
Thanks in advance.
-
Josh Lee, Lazarus programmer
« Last Edit: June 30, 2010, 10:51:35 am by Joshuzzz »
Linux Mint 12
Windows 7 Home Premium
______________________
Definition of programmer: An organism that converts caffeine into software.

IndianaJones

  • Hero Member
  • *****
  • Posts: 509
Re: Port Forwarding Help
« Reply #1 on: June 28, 2010, 12:47:29 am »

In your modem settings, you just need to enter three things for port forwarding.
The server IP, Protocol type (TCP, UDP or TCP&UDP) and port (which your application use it).
In my modem settings, there is an option under the NAT. In this option which ic Port Forwarding just enter the given information.
Anyway if you dont mind can you share the source code with other lazarus users?
Thanks.

Jishaxe

  • Full Member
  • ***
  • Posts: 103
  • Hobbist Programmer
Re: Port Forwarding Help
« Reply #2 on: June 28, 2010, 10:39:33 am »
Thanks for your help, just a few more questions if you would be nice to answer them please.
I'm a desktop programmer, but starting to move on to network programming.
Quote
The server IP, Protocol type (TCP, UDP or TCP&UDP) and port (which your application use it).
So as long as all my applications use the same port, they would be allowed through?

Also, what do I need to make a simple pair of applications that exchanges strings over global Internet? A static IP? And
Quote
The server IP,
How do I obtain this?
I'm sorry, I'm very basic on networking and need clarification please.
Linux Mint 12
Windows 7 Home Premium
______________________
Definition of programmer: An organism that converts caffeine into software.

IndianaJones

  • Hero Member
  • *****
  • Posts: 509
Re: Port Forwarding Help
« Reply #3 on: June 28, 2010, 01:39:46 pm »

If I understand your reply clearly, my port definition in here is different than yours. I mean, the port is a number which server side use for listening incoming client request. (like ssh using 22).
For the second question, where is your server side application running? The server program runs on a machine so that's your server ip address. To obtain the server ip if it is a Linux machine open a terminal and execute the following.

ifconfig -a

If your server side machine is a Windows machine then open a terminal and execute the following command. (start/run/cmd/ok)

ipconfig

I hope this will lead the way, if you have a problem feel free to ask.
Thanks.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10542
  • Debugger - SynEdit - and more
    • wiki
Re: Port Forwarding Help
« Reply #4 on: June 28, 2010, 02:31:40 pm »
I'm a desktop programmer, but starting to move on to network programming.
Quote
The server IP, Protocol type (TCP, UDP or TCP&UDP) and port (which your application use it).
So as long as all my applications use the same port, they would be allowed through?

If you want to run your apps in parallel, then they can not use the same port.
(That is for the server apps, that is / The client app you do not worry about the port. It get's it automatically, and you will never notice)


Also before you come to port forwarding. The client app on your friends pc must know the IP that you have. And normally you have more than one.

1) Your router get's an IP from the Internet provider you use. This IP of the router is a public IP, to which you friend can connect.

2) Your PC gets a private IP (usually 192.xx.xx.xx), that your friend can never see. Only your router can see that.

That is why you tell your router to forward stuff.

Problem is that the public IP that your router has can change. (Some provider offer you a static IP for extra money).
It is easier to use something like dyndns. Many routers have buid in support for that.

The port forwarding depends a lot on your router.

Some router you can give a name to your PC, and tell the router to:
- listen to port XX
- forward to port ZZ on "name/device" (ZZ can be equal to XX)

With other routers you must specify an IP (instead of a named device).
Then it is better to configure your PC with a fixed IP, instead of using DHCP
- If you need help on this, you need: your routers internal IP, the netmask, and the DHCP range. From that people can tell you what to set up on your PC

Jishaxe

  • Full Member
  • ***
  • Posts: 103
  • Hobbist Programmer
Re: Port Forwarding Help
« Reply #5 on: June 28, 2010, 09:41:22 pm »
I realised your can't run two servers on the same port, I tried two at the same time and it bought up an exception.
I was planning to make several pairs of server/client applications, on the same port. But I'm not planning to run both servers at once.
So the server IP is the private IP on my machine?
Or am I not understanding things clearly?
Linux Mint 12
Windows 7 Home Premium
______________________
Definition of programmer: An organism that converts caffeine into software.

OpenLieroXor

  • New Member
  • *
  • Posts: 38
Re: Port Forwarding Help
« Reply #6 on: June 28, 2010, 11:48:47 pm »
Yes, the Server IP is the local address of machine which is running your server program.
Quote
I was planning to make several pairs of server/client applications
- I'm not sure if you know that one server can be connected with more than one client, so you can listen to one port for all clients. Or I misunderstood you :P

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10542
  • Debugger - SynEdit - and more
    • wiki
Re: Port Forwarding Help
« Reply #7 on: June 29, 2010, 01:54:25 am »
I realised your can't run two servers on the same port, I tried two at the same time and it bought up an exception.
I was planning to make several pairs of server/client applications, on the same port. But I'm not planning to run both servers at once.

- If they are different servers, I would advice to use different ports.
- If it is one server for many clients, you only need one server. A single server app can accept many connections (all on the same port)

So the server IP is the private IP on my machine?
Or am I not understanding things clearly?

You are on an ADSL or other home internet connection, right?

- If you have a server in a hosting/data center, then there is no private IP. The serer has the public IP, and that's what you use.

- If it is your home PC and there is a router, then the router has the public IP and you must give that public IP to the client apps.
That is why the router will get the connection, and needs to forward it.

Jishaxe

  • Full Member
  • ***
  • Posts: 103
  • Hobbist Programmer
Re: Port Forwarding Help
« Reply #8 on: June 29, 2010, 07:59:26 am »
Sorry - I didn't explain myself well.
The pairs of applications do different things. Like, one could be a chatroom and the other could be a database or something.
Anyway.
Is it a requirement to get a static IP? Or is there another way to keep the client connected to the server?
Oh, and yes I use a home computer connected to a router.
In my application I use LNet.
Hangon, what if I use dynDNS? Would this work?
Code: [Select]


Clientt.Connect(http://www.hostnamecreatedbydyndns.dnsalais.com,port);


Will this work?
Sorry about my scattered post, I'm tired...
« Last Edit: June 29, 2010, 08:12:06 am by Joshuzzz »
Linux Mint 12
Windows 7 Home Premium
______________________
Definition of programmer: An organism that converts caffeine into software.

OpenLieroXor

  • New Member
  • *
  • Posts: 38
Re: Port Forwarding Help
« Reply #9 on: June 29, 2010, 09:31:38 am »
Yes, you can connect to host by the DNS domain, including domains generated by DDNS. You enter the hostname like an IP address, as string.

Jishaxe

  • Full Member
  • ***
  • Posts: 103
  • Hobbist Programmer
Re: [SOLVED, THANKS FOR HELP] Port Forwarding Help
« Reply #10 on: July 09, 2010, 09:49:15 pm »
Hm, another question.
How exactly do I connect to my server with another computer connected to my router?
I use LNet.
Code: Pascal  [Select][+][-]
  1. Serverr.Listen(23);
  2.  
Listens at port 23, yet I can not connect to my server over the router using a host generated by DynDNS. The DDNS host was mapped to what it said was 'my current IP address'.
Code: Pascal  [Select][+][-]
  1. Clientt.Connect('madhouserot.selfip.com',23);
  2. // But this doesn't work either.
  3. Clientt.Connect('95.147.180.84',23); //My 'current IP address'
  4.  
What am I doing wrong?
Linux Mint 12
Windows 7 Home Premium
______________________
Definition of programmer: An organism that converts caffeine into software.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10542
  • Debugger - SynEdit - and more
    • wiki
Re: [SOLVED, THANKS FOR HELP] Port Forwarding Help
« Reply #11 on: July 10, 2010, 02:11:07 am »
Either use the server local/private IP (192.x.x.x) or set up another port forward for port 23

95.147.180.84 is NOT your server => it is the IP of your router => so you try to connect to the router.

 

TinyPortal © 2005-2018