Linux network programming Common header files

Source: Internet
Author: User

SYS/TYPES.H: Data type definition

Sys/socket.h: Provides socket functions and data structures

Netinet/in.h: Defining Data Structures sockaddr_in

Arpa/inet.h: provides IP address translation functions

Netdb.h: Provides functions for setting and retrieving domain names

Sys/ioctl.h: Provides functions for I/O control

Sys/poll.h: A function that provides a socket wait test mechanism

Other header files that are common in network programs

Unistd.h: Provides common functions for files, directories, programs, and process operations

Errno.h: Provides the definition of error number errno for error handling

Fcntl.h: Provides functions for file control

Time.h: Provides a function about time

Crypt.h: Provides cryptographic functions that use the DES encryption algorithm

Pwd.h: Provides functions for/etc/passwd file access

Shadow.h: Provides functions for/etc/shadow file access

Pthread.h: Functions that provide multithreaded operations

Signal.h: Provides functions for signal manipulation

Sys/wait.h, sys/ipc.h, sys/shm.h: functions that provide process waiting, interprocess communication (IPC), and shared memory

Recommendation: When writing a network program, you can directly use the following header file code

#include <unistd.h>

#include <sys/types.h>

#include <sys/socket.h>

#include <netdb.h>

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include <ctype.h>

#include <errno.h>

#include <malloc.h>

#include <netinet/in.h>

#include <arpa/inet.h>

#include <sys/ioctl.h>

#include <stdarg.h>

#include <fcntl.h>

#include <fcntl.h>

Include the following statement when it comes to user rights and password validation issues:

#include <shadow.h>

#include <crypt.h>

#include <pwd.h>

It should be noted that the cryptographic algorithm library should be linked at compile time, that is, the compiler option is increased:-lcrypt

involves file and time operations add the following statement:

#include <sys/time.h>

#include <utime.h>

#include <time.h>

#include <sys/stat.h>

#include <sys/file.h>

When it comes to multi-process operations, add the following statement:

#include <sys/wait.h>

#include <sys/ipc.h>

#include <sys/shm.h>

#include <signal.h>

When it comes to multithreaded operations, add the following statement:

#include <pthread.h>

#include <sys/poll.h>

It should be noted that the compile-time link should be wired libraries, that is, the compiler option is increased:-lthread

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.