socket编程bind出错,因为绑定重复的地址和端口

来源:互联网 发布:进出货软件 编辑:程序博客网 时间:2024/06/05 04:33
        int flag=1,flaglen=sizeof(int);        if ( (sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0)        {                perror("socket");                PR_LOG(bluetooth_lm, PR_LOG_DEBUG, ("[%s] socket function fail < 0", __func__) );                return;        }        if( setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &flag, flaglen) == -1)        {                perror("setsockopt");                PR_LOG(bluetooth_lm, PR_LOG_DEBUG, ("[%s] setsockopt fail", __func__) );                return;        }        if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0)        {                perror("bind");                PR_LOG(bluetooth_lm, PR_LOG_DEBUG, ("[%s] bind function fail < 0", __func__) );                return;        }
阅读全文
0 0
原创粉丝点击