⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 idwinsock2.pas

📁 网络控件适用于Delphi6
💻 PAS
📖 第 1 页 / 共 5 页
字号:
{ $HDR$}
{**********************************************************************}
{ Unit archived using Team Coherence                                   }
{ Team Coherence is Copyright 2002 by Quality Software Components      }
{                                                                      }
{ For further information / comments, visit our WEB site at            }
{ http://www.TeamCoherence.com                                         }
{**********************************************************************}
{}
{ $Log:  56400: IdWinsock2.pas 
{
{   Rev 1.0    2004.02.03 3:14:50 PM  czhower
{ Move and updates
}
{
{   Rev 1.15    1/3/2004 12:41:48 AM  BGooijen
{ Fixed WSAEnumProtocols
}
{
    Rev 1.14    10/15/2003 1:20:48 PM  DSiders
  Added localization comments.
}
{
{   Rev 1.13    2003.10.01 11:16:38 AM  czhower
{ .Net
}
{
{   Rev 1.12    9/24/2003 09:18:24 AM  JPMugaas
{ Fixed an AV that happened when a stack call was made.
}
{
{   Rev 1.11    24/9/2003 3:11:34 PM  SGrobety
{ First wave of fixes for compiling in dotnet. Still not functional, needed to
{ unlock to fix critical failure in Delphi code
}
{
{   Rev 1.10    9/22/2003 11:20:14 PM  EHill
{ Removed assembly code and replaced with defined API stubs.
}
{
    Rev 1.9    7/7/2003 12:55:10 PM  BGooijen
  Fixed ServiceQueryTransmitFile, and made it public
}
{
{   Rev 1.8    2003.05.09 10:59:30 PM  czhower
}
{
    Rev 1.7    4/19/2003 10:28:24 PM  BGooijen
  some functions were linked to the wrong dll
}
{
{   Rev 1.6    4/19/2003 11:14:40 AM  JPMugaas
{ Made some tentitive wrapper functions for some things that should be called
{ from the Service Provider.  Fixed WSARecvMsg.
}
{
{   Rev 1.5    4/19/2003 02:29:26 AM  JPMugaas
{ Added TransmitPackets API function call.  Note that this is only supported in
{ Windows XP or later.
}
{
    Rev 1.4    4/19/2003 12:22:58 AM  BGooijen
  fixed: ConnectEx DisconnectEx WSARecvMsg
}
{
{   Rev 1.3    4/18/2003 12:00:58 AM  JPMugaas
{ added
{ ConnectEx
{ DisconnectEx
{ WSARecvMsg
{
{ Changed header procedure type names to be consistant with the old
{ IdWinsock.pas in Indy 8.0 and with the rest of the unit.
}
{
{   Rev 1.2    3/22/2003 10:01:26 PM  JPMugaas
{ WSACreateEvent couldn't load because of a space.
}
{
{   Rev 1.1    3/22/2003 09:46:54 PM  JPMugaas
{ It turns out that we really do not need the TGUID defination in the header at
{ all.  It's defined in D4, D5, D6, and D7.
}
{
{   Rev 1.0    11/13/2002 09:02:54 AM  JPMugaas
}
//-------------------------------------------------------------
//
//       Borland Delphi Runtime Library
//       <API> interface unit
//
// Portions created by Microsoft are
// Copyright (C) 1995-1999 Microsoft Corporation.
// All Rights Reserved.
//
// The original file is: Winsock2.h from CBuilder5 distribution.
// The original Pascal code is: winsock2.pas, released 03 Mar 2001.
// The initial developer of the Pascal code is Alex Konshin
// (alexk@mtgroup.ru).
//-------------------------------------------------------------


{ Winsock2.h -- definitions to be used with the WinSock 2 DLL and WinSock 2 applications.
  This header file corresponds to version 2.2.x of the WinSock API specification.
  This file includes parts which are Copyright (c) 1982-1986 Regents
  of the University of California. All rights reserved.
  The Berkeley Software License Agreement specifies the terms and
  conditions for redistribution. }

// Note that the original unit is copyrighted by the original author and I did obtain his
// permission to port and use this as part of Indy - J. Peter Mugaas

// 2002-01-28 - Hadi Hariri. Fixes for C++ Builder. Thanks to Chuck Smith.
// 2001 - Oct -25  J. Peter Mugaas
//    Made adjustments for Indy usage by
//    1) including removing Trace logging
//    2) renaming and consolidating some .INC files as appropriate
//    3) modifying the unit to follow Indy conventions
//    4) Adding TransmitFile support for the HTTP Server
//    5) Removing all static loading code that was IFDEF'ed.    {Do not Localize}
// 2001 - Mar - 1  Alex Konshin
// Revision 3
// converted by Alex Konshin, mailto:alexk@mtgroup.ru
// revision 3, March,1 2001


unit IdWinSock2;

interface

{$ALIGN OFF}
{$RANGECHECKS OFF}
{$WRITEABLECONST OFF}

uses SysUtils, Windows, IdException;

type
  EIdWinsockStubError = class(EIdException)
  protected
    FWin32Error : DWORD;
    FWin32ErrorMessage : String;
    FTitle : String;
  public
    constructor Build(const ATitle : String; AWin32Error : DWORD );
    property Win32Error : DWORD read FWin32Error;
    property Win32ErrorMessage : String read FWin32ErrorMessage;
    property Title : String read FTitle;
  end;


{$DEFINE WS2_DLL_FUNC_VARS}
{$DEFINE INCL_WINSOCK_API_PROTOTYPES}



//  Define the current Winsock version. To build an earlier Winsock version
//  application redefine this value prior to including Winsock2.h
const
  winsock_version = $0202;
  winsock2_dll = 'WS2_32.DLL';    {Do not Localize}

type
  u_char  = Byte;
  u_short = Word;
  //u_int   = DWORD;
  u_int   = Integer;
  u_long  = DWORD;
// The new type to be used in all instances which refer to sockets.
  TSocket = u_int;

  wsaevent = THandle;
  Pwsaevent = ^wsaevent;
  LPwsaevent = Pwsaevent;
{$IFDEF UNICODE}
  PMBChar = PWideChar;
{$ELSE}
  PMBChar = PChar;
{$ENDIF}

const
  fd_setsize     =   64;

type
  PFDSet = ^TFDSet;
  TFDSet = packed record
    fd_count: u_int;
    fd_array: array[0..fd_setsizE-1] of TSocket;
  end;

  PTimeVal = ^TTimeVal;
  TTimeVal = packed record
    tv_sec: Longint;
    tv_usec: Longint;
  end;

const
  iocparm_mask = $7f;
  ioc_void     = $20000000;
  ioc_out      = $40000000;
  ioc_in       = $80000000;
  ioc_inout    = (IOC_IN or IOC_OUT);

// get # bytes to read
  fionread     = ioc_out or (SizeOf(Longint) shl 16) or (Ord('f') shl 8) or 127;    {Do not Localize}
// set/clear non-blocking i/o
  fionbio      = ioc_in  or (SizeOf(Longint) shl 16) or (Ord('f') shl 8) or 126;    {Do not Localize}
// set/clear async i/o
  fioasync     = ioc_in  or (SizeOf(Longint) shl 16) or (Ord('f') shl 8) or 125;    {Do not Localize}

//  Socket I/O Controls

// set high watermark
  siocshiwat   = ioc_in  or (SizeOf(Longint) shl 16) or (Ord('s') shl 8);    {Do not Localize}
// get high watermark
  siocghiwat   = ioc_out or (SizeOf(Longint) shl 16) or (Ord('s') shl 8) or 1;    {Do not Localize}
// set low watermark
  siocslowat   = ioc_in  or (SizeOf(Longint) shl 16) or (Ord('s') shl 8) or 2;    {Do not Localize}
// get low watermark
  siocglowat   = ioc_out or (SizeOf(Longint) shl 16) or (Ord('s') shl 8) or 3;    {Do not Localize}
// at oob mark?
  siocatmark   = ioc_out or (SizeOf(Longint) shl 16) or (Ord('s') shl 8) or 7;    {Do not Localize}


//  Structures returned by network data base library, taken from the
//  BSD file netdb.h.  All addresses are supplied in host order, and
//  returned in network order (suitable for use in system calls).
type
  PHostEnt = ^THostEnt;
  THostEnt = packed record
    h_name: PChar;                 // official name of host
    h_aliases: ^PChar;             // alias list
    h_addrtype: Smallint;          // host address type
    h_length: Smallint;            // length of address
    case Byte of
      0: (h_address_list: ^PChar);
      1: (h_addr: ^PChar);         // address, for backward compat
  end;

//  It is assumed here that a network number
//  fits in 32 bits.
  PNetEnt = ^TNetEnt;
  TNetEnt = packed record
    n_name: PChar;                 // official name of net
    n_aliases: ^PChar;             // alias list
    n_addrtype: Smallint;          // net address type
    n_net: u_long;                 // network #
  end;

  PServEnt = ^TServEnt;
  TServEnt = packed record
    s_name: PChar;                 // official service name
    s_aliases: ^PChar;             // alias list
    s_port: Smallint;              // protocol to use
    s_proto: PChar;                // port #
  end;

  PProtoEnt = ^TProtoEnt;
  TProtoEnt = packed record
    p_name: PChar;                 // official protocol name
    p_aliases: ^Pchar;             // alias list
    p_proto: Smallint;             // protocol #
  end;

// Constants and structures defined by the internet system,
// Per RFC 790, September 1981, taken from the BSD file netinet/in.h.
const

// Protocols
  ipproto_ip     =   0;             // dummy for IP
  ipproto_icmp   =   1;             // control message protocol
  ipproto_igmp   =   2;             // group management protocol
  ipproto_ggp    =   3;             // gateway^2 (deprecated)
  ipproto_tcp    =   6;             // TCP
  ipproto_pup    =  12;             // pup
  ipproto_udp    =  17;             // UDP - user datagram protocol
  ipproto_idp    =  22;             // xns idp
  ipproto_ipv6   =  41;             // IPv6
  ipproto_nd     =  77;             // UNOFFICIAL net disk proto
  ipproto_iclfxbm = 78;

  ipproto_raw    = 255;             // raw IP packet
  ipproto_max    = 256;

// Port/socket numbers: network standard functions
  ipport_echo        =   7;
  ipport_discard     =   9;
  ipport_systat      =  11;
  ipport_daytime     =  13;
  ipport_netstat     =  15;
  ipport_ftp         =  21;
  ipport_telnet      =  23;
  ipport_smtp        =  25;
  ipport_timeserver  =  37;
  ipport_nameserver  =  42;
  ipport_whois       =  43;
  ipport_mtp         =  57;

// Port/socket numbers: host specific functions
  ipport_tftp        =  69;
  ipport_rje         =  77;
  ipport_finger      =  79;
  ipport_ttylink     =  87;
  ipport_supdup      =  95;

// UNIX TCP sockets
  ipport_execserver  = 512;
  ipport_loginserver = 513;
  ipport_cmdserver   = 514;
  ipport_efsserver   = 520;

// UNIX UDP sockets
  ipport_biffudp     = 512;
  ipport_whoserver   = 513;
  ipport_routeserver = 520;

// Ports < IPPORT_RESERVED are reserved for  privileged processes (e.g. root).
  ipport_reserved    =1024;

// Link numbers
  implink_ip         = 155;
  implink_lowexper   = 156;
  implink_highexper  = 158;

  //transmit file flag values

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -