Unix Network Programming Volume 1

Source: Internet
Author: User
Tags socket
Chapter 1

Chapter 2 TCP

Server passive open (passive open): Socket, bind, listen. The client is actively opened via the socket, connect (active open). Accept and connect are blocked

UDP UDP can be a full-duplex Chapter 3 - byte sort function

Low-order bytes are stored in the start Address: small End (Little-endian) byte order; high-order bytes are stored in the start address: big-endian (Big-endian) byte order. The Internet protocol uses big-endian byte-order to transmit these multibyte integers.

byte manipulation functions

#include <string.h>

//Set the specified number of bytes in the destination byte string to c
void *memset (void *dest, int c, size_t len);

Moves the specified number of bytes from the original byte to the target string
void *memcpy (void *dest, const void *SRC, size_t nbytes);

Compare byte strings, return the same 0
int memcpy (const void *ptrl, const void *PTR2, size_t nbytes);
Readn, writen, ReadLine functions

A byte-stream socket call read or write input or output may have fewer bytes than requested, however this is not a faulted state because the buffer used for sockets in the kernel has reached its limit.

Text line-based network protocol: SMTP, HTTP, FTP, etc. Chapter 4

fork and EXEC functions

#include <unistd.h>

//child process returns 0, the parent process returns the child process ID
pid_t fork (void);

Exec replaces the current process image with a new program file, the process ID is unchanged

The 6 exec functions are different:

Concurrent Server Profiles

Why does the parent process call close to CONNFD does not terminate its link to the customer? Because each file or socket has a reference count:

Most TCP servers are concurrent, and they derive a child process for each pending client link call fork. Most UDP servers are iterative.

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.