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