Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Hands-On Network Programming with C

You're reading from   Hands-On Network Programming with C Learn socket programming in C and write secure and optimized network code

Arrow left icon
Product type Paperback
Published in May 2019
Publisher Packt
ISBN-13 9781789349863
Length 478 pages
Edition 1st Edition
Languages
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Lewis Van Winkle Lewis Van Winkle
Author Profile Icon Lewis Van Winkle
Lewis Van Winkle
Arrow right icon
View More author details
Toc

Table of Contents (26) Chapters Close

Title Page
Copyright and Credits
Dedication
About Packt Contributors Preface 1. Introducing Networks and Protocols FREE CHAPTER 2. Getting to Grips with Socket APIs 3. An In-Depth Overview of TCP Connections 4. Establishing UDP Connections 5. Hostname Resolution and DNS 6. Building a Simple Web Client 7. Building a Simple Web Server 8. Making Your Program Send Email 9. Loading Secure Web Pages with HTTPS and OpenSSL 10. Implementing a Secure Web Server 11. Establishing SSH Connections with libssh 12. Network Monitoring and Security 13. Socket Programming Tips and Pitfalls 14. Web Programming for the Internet of Things 1. Answers to Questions 2. Setting Up Your C Compiler on Windows 3. Setting Up Your C Compiler on Linux 4. Setting Up Your C Compiler on macOS 5. Example Programs 6. Other Book You May Enjoy

Installing libssh

You can obtain the latest libssh library from https://www.libssh.org/. If you are proficient in installing C libraries, feel free to give it a go. Otherwise, read on for step-by-step instructions.

Before beginning, be sure that you've first installed the OpenSSL libraries successfully. These are required by the libssh library.

We will need CMake installed in order to build libssh. You can obtain CMake from https://cmake.org/. They provide a nice GUI installer, and you shouldn't run into any difficulties. Make sure you select the option to add CMake to your PATH during installation:

Once you have the CMake tool and the OpenSSL libraries installed, navigate to the libssh website to download the libssh source code. At the time of writing, Version 0.8.7 is the latest, and it is available from https://www.libssh.org/files/0.8/. Download and extract the libssh source code.

Take a look at the included INSTALL file.

Now, open a command window in the libssh source code directory. Create a new build folder with the following commands:

mkdir build
cd build

Keep this command window open. We'll do the build here in a minute.

Start CMake 3.14.3 (cmake-gui) from the start menu or desktop shortcut.

You need to set the source code and build locations using the Browse Source... and Browse Build... buttons. This is shown in the following screenshot:

Then, click Configure.

On the next screen, select MinGW Makefiles as the generator for this project. Click Finish.

It may take a moment to process.

From the configuration options, make the following changes:

  1. Uncheck WITH_NACL
  2. Uncheck WITH_GSSAPI
  3. Change CMAKE_INSTALL_PREFIX to c:\mingw

Then, click Configure again. It will take a moment. If everything worked, click Generate.

You should now be able to build libssh.

Go back to your command window in the build directory. Use the following command to complete the build:

mingw32-make

After the build completes, use the following command to copy the files over to your MinGW installation:

mingw32-make install

You can try building ssh_version.c from Chapter 11, Establishing SSH Connections with libssh, to test that everything is installed correctly. It should look like the following:

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime
Banner background image