Networking in C

We direct you to the excellent resource Beej's Guide to Network Programming and show how you can make use of the simple server and simple client using a Raspberry Pi.
  1. Compile the simple stream server (Section 6.1 of the guide) in a project named server.
  2. Compile the simple stream client (Section 6.2 of the guide) in a project named client.
  3. Open two LXTerminals and change directory if necessary to the working directory of Code::Blocks.
  4. Execute the server and then the client using the commands shown in this screenshot.
    Server and client in action

    Server and client in action

  5. You should be tempted to change the server so that it sends some useful information and to try other code in the guide.
  6. The guide (with many different language versions linked to on this page) is very informative so use it to study the theory.

As stated in the guide, you can test the server with telnet. Install it with the command sudo apt-get install telnet then access the simple stream server with the command telnet localhost 3490.

Remote access from a PC

You can use the telnet option within PuTTY on a PC to obtain the response from the server on a Pi on the same network. The screenshots show the configuration of PuTTY and the response.

Configuration of PuTTY

Configuration of PuTTY for accessing the simple server

Response from the simple server

Response from the simple server

Programming - a skill for life!

How to apply your knowledge of Pascal when learning C/C++