CSDN博客

img haiheng

(bind(sListen, (struct sockaddr *)&local, sizeof(local))//把socket与IP和端口

发表于2004/10/28 10:59:00  1658人阅读

struct sockaddr_in local,
 local.sin_addr.s_addr = htonl(INADDR_ANY);
    local.sin_family = AF_INET  //设置本地接收IP为本机IP
 iPort = 8000;     //设置本地接收端口为8000
    local.sin_port = htons(iPort);

    if (bind(sListen, (struct sockaddr *)&local,
            sizeof(local)) == SOCKET_ERROR)
    {
        printf("bind() failed: %d/n", WSAGetLastError());
        return 1;
    }

阅读全文
0 0

相关文章推荐

img
取 消
img