[SOLVED, THANKS FOR HELP] Port Forwarding Help lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- Jishaxe · 2010-06-27 12:22 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 ---------------------------------------------------------------------- IndianaJones · 2010-06-27 22:47 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 · 2010-06-28 08:39 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. QuoteThe 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 QuoteThe server IP,How do I obtain this? I'm sorry, I'm very basic on networking and need clarification please. ---------------------------------------------------------------------- IndianaJones · 2010-06-28 11:39 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 · 2010-06-28 12:31 Quote from: Joshuzzz on June 28, 2010, 10:39:33 amI'm a desktop programmer, but starting to move on to network programming. QuoteThe 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 · 2010-06-28 19:41 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? ---------------------------------------------------------------------- OpenLieroXor · 2010-06-28 21:48 Yes, the Server IP is the local address of machine which is running your server program. QuoteI 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 ---------------------------------------------------------------------- Martin_fr · 2010-06-28 23:54 Quote from: Joshuzzz on June 28, 2010, 09:41:22 pmI 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) Quote from: Joshuzzz on June 28, 2010, 09:41:22 pmSo 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 · 2010-06-29 05:59 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... ---------------------------------------------------------------------- OpenLieroXor · 2010-06-29 07:31 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 · 2010-07-09 19:49 Hm, another question. How exactly do I connect to my server with another computer connected to my router? I use LNet. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Serverr.Listen(23); 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][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Clientt.Connect('madhouserot.selfip.com',23);// But this doesn't work either.Clientt.Connect('95.147.180.84',23); //My 'current IP address' What am I doing wrong? ---------------------------------------------------------------------- Martin_fr · 2010-07-10 00:11 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.