/server-client-example-sys-socket.h

A TCP server/client example using sys/socket.h

Primary LanguageCCreative Commons Zero v1.0 UniversalCC0-1.0

Server/client example using <sys/socket.h>

At the source folder you would find an example of a simple TCP server/client example, which only accepts one client, and a Multiclient TCP server/client example using the library <sys/socket.h>

Summary

Getting started 🚀

Download the source's folder on your computer.

Pre-installation 📋

You need make packet to execute the files.

To install it:

sudo apt-get update
sudo apt-get install make

Return to summary

Installation 🔧

Open your cmd, go to the directory where you have downloaded the files typing this:

cd Documents/Projects/source/Simple\ TCP for example

Now you have to compile them, typing:

make server

And:

make client

Or if you prefer you can type:

make all

These commands works for both projects.

Return to summary

Deployment 📦

Then open some terminals and go to the directory where you have the files compiled.

It's very important to run the server before de client. At the first terminal run the server:

./server 8080

On the second the client:

./client 127.0.0.1 8080

When you do this you recieve a message on the server and on the client side saying that it was successfully or not in case of error. Once connected you can send messages to the host until you type "Exit" to get disconnected.

As you can see the format is ./server port_number and ./client hostname port_number so you can try whatever you want.

NOTE: with Simple TCP example the maximum number of terminals are two, however for Multiclient's example you can execute whatever you want.

Return to summary

How it works 🔨

Return to summary

Build with 🛠️

Return to summary

License 📄

This project is licensed under the CC0 1.0 Universal Creative Commons License - see the LICENSE.md file for details

Return to summary

Acknowledgments 📢

Return to summary