select monitors on stdout and sockets

The content of selectServerInTCPIPbook.c is as follows: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <arpa/inet.h> #include <sys/socket.h> #include <sys/time.h> #include <sys/select.h> #defineBUF_SIZE 100 void error_handling(char *buf); int main(int argc, char *argv[]) {<!– –> int serv_sock, clnt_sock; struct sockaddr_in serv_adr, clnt_adr; struct timeval timeout; fd_set reads, cpy_reads; socklen_t adr_sz; int fd_max, str_len, fd_num, i; […]

The difference between _cdecl and _stdcal and the function of extern “c

Article directory Purpose _stdcal _cdecl result dll extern “c” Replenish Purpose 1) Understand the difference between _cdecl and _stdcal under Windows, so that you can better use modified functions to make function calls. There are several calling methods, divided into C style and Pascal style. The overall difference. _cdecl (c/c++ default, supports variable parameter functions, […]

std::condition_variable condition variable and lock_guard, unique_lock

Used to block one thread, or block multiple threads at the same time, until another thread modifies the shared variable (condition) and notifies condition_variable. A thread that intentionally modifies a variable must Obtain std::mutex (often via std::lock_guard ) Modify while holding lock Perform notify_one or notify_all on std::condition_variable (no need to hold locks for notifications) […]

FastDFS+Nginx installation configuration

FastDFS + Nginx installation configuration Directory Download and upload the installation package to the server project address: FastDFS installation 1. Install FastDFS dependent libraries 1. Compilation environment 2. Install libfastcommon and libserverframe libraries 2. Install FastDFS and configure it 3. Start (choose one of the following startup methods) File mode startup Configure systemd startup 1. […]

C++20: std::jthread

Table of contents: 1. What is std::jthread? 2. Why introduce jthread? 3. How to use 3.1 Automatic join() 3.2 Thread interruption 4. Summary 1. What is std::jthread Class jthread represents a single thread of execution. It has the usual behavior of std::thread, except that jthread automatically recombines on destruction and can be canceled/stopped under specific […]

C/C++ 11/14 rewrites a std::function<…> function template that supports safety and no multiple copies, supports Lambda λ and overloaded operator()(…) operator structure and C/C++ language Ordinary functions.

As the title of this article indicates, it was rewritten for optimization, and the solid-size BUFF buffer provided by the standard library std::function implementation was cut off because it is no longer necessary. The implementation copies the shared pointer. Reference, instead of needing to copy the BUFF and reconstruct it like the official version. If […]

New threads: C++20 std::jthread

New threads: C++20 std::jthread Article directory 1. What is std::jthread? 2. Why introduce jthread? 3. How to use 3.1 Automatic join() 3.2 Thread interruption 4. Summary 1. What is std::jthread Class jthread represents a single thread of execution. It has the usual behavior of std::thread, except that jthread automatically recombines on destruction and can be […]

Use FastDFS and Nginx for port mapping to achieve remote access to local file servers

Article directory Preface 1. Build the FastDFS file system locally 1.1 Environment installation 1.2 Install libfastcommon 1.3 Install FastDFS 1.4 Configure Tracker 1.5 Configure Storage 1.6 Test upload and download 1.7 Integration with Nginx 1.8 Install Nginx 1.9 Configure Nginx 2. LAN test access to FastDFS 3. Install cpolar intranet penetration 4. Configure public network […]

[Installation] Self-built Rustdesk Server

Article directory RustDesk description RustDesk Advantages RustDesk related links Non-Docker based on CentOS RustDesk default program occupied port description Start hbbr as a relay server Start hbbs which is the ID server Client configuration Write startup script Detailed description of hbbr and hbbs commands RustDesk description RustDesk Advantages Build your own server. Building on your […]

std::function and bind binders for C++11

Callable object In C++, there is a concept of “callable object”. To be precise, callable objects have the following definitions: 1. It is a function pointer 2. It is a class object (functor) with operator() member function 3. It is a class object that can be converted into a function pointer. 4. It is a […]