如题.

解决方案 »

  1.   

    The Windows Sockets getsservbyname function gets service information corresponding to a service name and protocol.struct servent FAR * getservbyname (    const char FAR * name,
        const char FAR * proto
       );
     Parametersname[in] A pointer to a null terminated service name.proto[in] An optional pointer to a null terminated protocol name. If this pointer is NULL, getservbyname returns the first service entry for which the name matches the s_name or one of the s_aliases. Otherwise, getservbyname matches both the name and the proto. Resgetservbyname returns a pointer to the following structure which contains the name(s) and service number which correspond to the given service name. All strings are null terminated.struct servent {
        char FAR *        s_name;
        char FAR * FAR *  s_aliases;
        short             s_port;
        char FAR *        s_proto;
    };
      The members of this structure are:Element Usage
    s_name Official name of the service.
    s_aliases A NULL-terminated array of alternate names.
    s_port The port number at which the service can be contacted. Port numbers are returned in network byte order.
    s_proto The name of the protocol to use when contacting the service.
     The pointer which is returned points to a structure which is allocated by the Windows Sockets library. The application must never attempt to modify this structure or to free any of its components. Furthermore only one copy of this structure is allocated per thread, and so the application should copy any information which it needs before issuing any other Windows Sockets function calls.Return ValuesIf no error occurs, getservbyname returns a pointer to the servent structure described above. Otherwise, it returns a NULL pointer and a specific error number can be retrieved by calling WSAGetLastError.Error CodesWSANOTINITIALISED A successful WSAStartup must occur before using this function.
    WSAENETDOWN The network subsystem has failed.
    WSAHOST_NOT_FOUND Authoritative Answer Service not found.
    WSATRY_AGAIN Non-Authoritative Service not found, or server failure.
    WSANO_RECOVERY Nonrecoverable errors, the services database is not accessible.
    WSANO_DATA Valid name, no data record of requested type.
    WSAEINPROGRESS A blocking Windows Sockets 1.1 call is in progress, or the service provider is still processing a callback function.
    WSAEINTR The (blocking) call was canceled through WSACancelBlockingCall.
      

  2.   

    PortNo:=AClientSocket.LookupService('http');
      

  3.   

    AClientSocket.LookupService('Apache2')
    不行,我要得到Apache2或sql服务端口号.