Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I built a tcp chat program for a Local area network(LAN)
I want to expand the program outside the LAN so i can acces it from anywhere in the world if i have to.

My questions are:
- what is socket programming and is this what i need
- how can open a port to allow trafic to be sent and recieved.
- are there any security problems

I'm pretty new to programming network applications. i have done some FTP file transfer apps but tcp is new to me
Posted
Updated 21-Apr-13 2:34am
v2

If you already have a chatprogram that works on your LAN that uses sockets you can just open up the ports in your firewall(s) to allow the traffic to be send and received. As long as you don't use any ports below 1024 you should be fine.

Anyone will be able to connect to that port though so you may want to add a whitelist (IP) to your firewall rule or some authentiation function to the program itself.
 
Share this answer
 
Hi,
Your questions are very broad, so if while answering I cover parts that seem obvious, or that you already know, please forgive me.

1.) What is socket programming, and is this what I need

A socket is a logical construct (class or object) that we use to communicate between computers on a network. It contains the underlying functionality to access and control your network hardware, and for the most part insulates you from it. This way you can simply create a socket and use it without having to worry about details like drivers, the manufacturer of your network card, ect. If you are using TCP to do the communicating, the size of the network is unimportant because TCP is a route-able protocol. This means that you can use TCP to communicate with computers across the internet. Each computer can communicate with up to 65536 other computers at the same time using special communication channels called "ports". A socket server "listens" on a specific port, and a socket client attempts to connect to a socket server on a specific port. It is possible to have a separate server application listening on every port on a computer.

The first 1024 ports (or so) have already been claimed by various operating system services and applications, so you should avoid using them. In fact, when choosing a port for your application, you should do an internet search for other applications that use the port you've selected to see if you may have conflicts with that application in the future.

So - is this what you need? If you want your chat program to be available across the internet, then YES.

2.) How can I open a port to allow traffic to be sent and received.

To "open" a port, you will need to configure your router and / or firewall. You will likely need to configure Windows Firewall also. You will need to do something called "Port Forwarding" - meaning you will need to tell your router or firewall that it needs to send incoming traffic to your WAN (Wide Area Network) IP address on a specific port to a LAN (Local area Network) computer's IP address on a specific port. Each router or firewall's configuration will be different, and listing them all here would be impossible. You will need to google this subject, and figure out how to configure your router of firewall. You should do the same with windows firewall, although you can pragmatically add your application to the list of allowed applications during installation. You can find an example of how to do that here.

3.) Are there any security problems?
There are security CONCERNS, but only you can introduce security problems. Of course, during the coding of network applications we all do our best to avoid this. You can find a discussion on best practices for secure network communications here.

I hope I've answered your question. If you feel that I have, please feel free to click the "accept solution" button.

- Pete
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900