Einzelnen Beitrag anzeigen

Benutzerbild von APP
APP

Registriert seit: 24. Feb 2003
Ort: Graz (A)
705 Beiträge
 
Delphi 7 Enterprise
 
#19

Re: Welcher Dienst hinter welchem Port?

  Alt 5. Mär 2004, 18:01
Hallo Gregor,
mal schnell zusammengezimmert:

Delphi-Quellcode:
VAR
  p : PServEnt;
  WSAData : TWSADATA;
  Port : DWORD;
BEGIN
  // FTP
  Port := 21;
  IF WsaStartup(MakeWord(2, 0), WSAData) = 0 THEN
  TRY
    // Achtung, Port muss in Network Byte Order vorliegen
    p := getservbyport(hTons(Port), NIL);
    IF WSAGetLastError = 0 THEN
      BEGIN
        IF p <> NIL THEN
          BEGIN
            Edit1.Text := p^.s_name;
          END;
      END
    ELSE
      BEGIN
        CASE WSAGetLastError OF
          WSANOTINITIALISED: ShowMessage('A successful WSAStartup call must occur before using this function');
          WSAENETDOWN: ShowMessage('The network subsystem has failed.');
          WSAHOST_NOT_FOUND: ShowMessage('Authoritative Answer Service not found.');
          WSATRY_AGAIN: ShowMessage('A nonauthoritative Service not found, or server failure.');
          WSANO_RECOVERY: ShowMessage('Nonrecoverable errors, the services database is not accessible.');
          WSANO_DATA: ShowMessage('Valid name, no data record of requested type.');
          WSAEINPROGRESS: ShowMessage('A blocking Windows Sockets 1.1 call is in progress, or the service provider is still processing a callback function.');
          WSAEFAULT: ShowMessage('The proto parameter is not a valid part of the user address space.');
          WSAEINTR: ShowMessage('A blocking Windows Socket 1.1 call was canceled through WSACancelBlockingCall.');
        END;
      END;
  FINALLY
    WSACleanup;
  END;
END;
Armin P. Pressler

BEGIN
...real programmers are using C/C++ - smart developers Delphi;
END;
  Mit Zitat antworten Zitat