Windows Sockets 1.1应用实例(139)

2010-12-30 20:58:11 · 作者: · 浏览: 62973
sp;      return (SOCKET) -1;            /* Unknown protocol */

    }

   

    /* default port to connect to. Must be in network byte order      */

    dest.sin_port = htons((u_int) iSockPort);

   

    SetDlgItemText(hOurDlg, IDD_COMMENT,"Resolving hostname...");

   

    /* Resolve the host name */

    host_ptr = gethostbyname(lpHostName);

    if (host_ptr == NULL) {

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

       return (SOCKET) -1;

    }

    /* Patch host address into struct describing conn: */

    bcopy(host_ptr->h_addr,&dest.sin_addr,host_ptr->h_length);

   

 &