Advertisement

SIGURG信号:外部干扰的处理

阅读量:

采用SIGURG对带外数据进行处理的程序实例:

复制代码
    #include <sys/socket.h>
    #include <netinet/in.h>
    #include <arpa/inet.h>
    #include <assert.h>
    #include <stdio.h>
    #include <unistd.h>
    #include <stdlib.h>
    #include <errno.h>
    #include <string.h>
    #include <signal.h
    #include <fcntl.h>
    
    #define BUFSIZE 1024
    
    static int connfd;
    
    /*SIGURG信号处理函数*/
    void sig_urg(int urg)
    {
    int save_errno = errno;
    char buffer[BUFSIZE];
    memset(buffer, '\0', BUFSIZE);
    int ret = recv(connfd, buffer, BUFSIZE-1 , MSG_OOB);/*MSG_OOB标志 接收带外数据*/
    printf("接收到%d数

全部评论 (0)

还没有任何评论哟~