Windows Sockets 1.1应用实例(142)

2010-12-30 20:58:11 · 作者: · 浏览: 62963
kType = SOCK_DGRAM;

    }

   

    memset(&local, '\0', sizeof (local));

    local.sin_family = PF_INET;

    local.sin_port = htons((u_short)iSockPort);

   

    /* allocate a socket descriptor */

    hSock = socket(PF_INET, iSockType, 0);

    if (hSock == INVALID_SOCKET) { /* socket() failed       */

       wshout_err (hOurDlg, WSAGetLastError(), "socket()");

       return (SOCKET) -1;

    }

   

    /* bind socket to a local addr */

    ret = bind(hSock, (struct sockaddr FAR *) &local, sizeof(local));

    if (ret == SOCKET_ERROR){          /* bind() failed           */

    &