#include <stdio.h>#include <stdlib.h>#include <string.h>#include <ctype.h># Include <sys/un.h>#include <sys/ioctl.h>#include <sys/socket.h>#include <linux/types.h>#include <linux/netlink.h># Include <errno.h>#define UEVENT_BUFFER_SIZE 2048static int init_hotplug_sock(void);int main(int argc, char* argv[]){int hotplug_sock = init_hotplug_sock();while(1){char buf[UEVENT_BUFFER_SIZE*2] = {0};recv(hotplug_sock, &buf, sizeof(buf), 0); printf("%s\ ", buf);}return 0;}static int init_hotplug_sock(void){struct sockaddr_nl snl;const int Buffersize = 16 * 1024 * 1024; int retval;memset(&snl, 0x00, sizeof(struct sockaddr_nl));snl.nl_family = AF_NETLINK;snl.nl_pid = getpid();snl.nl_groups = 1;int hotplug_sock = socket (PF_NETLINK, SOCK_DGRAM, NETLINK_KOBJECT_UEVENT); if (hotplug_sock == -1) {printf("error getting socket: %s", strerror(errno));return -1;}/* set r Eceive buffersize */setsockopt(hotplug_sock, SOL_SOCKET, SO_RCVBUFFORCE, &buffersize, sizeof(buffersize));retval = bind(hotplug_sock, (struct sockaddr *) &snl, sizeof(struct sockaddr_nl));if (retval < 0 {printf("bind failed: %s", strerror(errno));close(hotplug_sock);hotplug_sock = -1;return -1;}return hotplug_sock;}
This period win8.1 Mac OS X 10.9 Mavericks Two operating systems almost simultaneously released, i
1. In STM32, there are five clock sources, HSI, HSE, LSI, LSE, PLL. 1, HSI is a high-speed internal
First look at the TCP server side of the program: #include <stdlib.h> #include <stdio.h>
Today, I have brought the steps of adding static routes for Linux, I hope to help my friends! 1. Add
What is Linux? What are the characteristics? Linux Literacy
Shell file set weight naming method (Rename!)
PXE+TFTP+DHCP network automatically boots and installs Linux
Configure dual NIC routing table
Install libxml2 "bin/rm: cannot remove `libtoolT: No such file
centOS automatically installs php
ADSL telephone line interference causes the network to drop frequently
CentOS 6.x uses yum to install nginx environment
Linux generates random password/modify password
Basic knowledge about linux graphical interface
Windows7 system wallpaper can not be centered how to do
Win7 system boot animation shutdown method
Win10 start menu tile how to set
U disk method to break XP administrator password
Combined with examples to understand the built-in AT command in Windows XP
My machine is controlled by me. It is forbidden by Win XP. It is
Linux history (history) command usage detailed
Windows 7 system uses multi-threading to speed up file copying? (2)
Eight bad habits that seriously affect the speed of computer response