中国程序员联盟 正在重新改版中ing 不便之处还请见谅 改版后将内容涉及java delphi .net php
 
  首页 | 数据库开发 | 网络通讯 | 多线程 | 多媒体开发 | 图像处理 | 程序人生 | 系统函数 | 控件开发 | Web服务
 
  当前位置:笨鱼delphi技术网>多线程>文章内容

delphi winsock2 网络编程(中)

来源:站内 关于:bill 发布时间:2007-07-09   [收藏] [推荐]
type
{ Structure used for manipulating linger option. }
  PLinger = ^TLinger;
  TLinger = packed record
    l_onoff: u_short;
    l_linger: u_short;
  end;
const
{ Level number for (get/set)sockopt() to apply to socket itself. }
  SOL_SOCKET      = $ffff;          {options for socket level }
{ Maximum queue length specifiable by listen. }
  SOMAXCONN       = $7fffffff;      { AHS - by³o 5 !?????? }
  MSG_OOB         = $1;             {process out-of-band data }
  MSG_PEEK        = $2;             {peek at incoming message }
  MSG_DONTROUTE   = $4;             {send without using routing tables }
  MSG_MAXIOVLEN   = 16;
  MSG_PARTIAL     = $8000;          {partial send or recv for message xport }
{ WinSock 2 extension -- new flags for WSASend(), WSASendTo(), WSARecv() and
  WSARecvFrom() }
  MSG_INTERRUPT   = $10;            {send/recv in the interrupt context}
{ Define constant based on rfc883, used by gethostbyxxxx() calls. }
  MAXGETHOSTSTRUCT        = 1024;
{ Define flags to be used with the WSAAsyncSelect() call. }
  FD_READ         = $01;
  FD_WRITE        = $02;
  FD_OOB          = $04;
  FD_ACCEPT       = $08;
  FD_CONNECT      = $10;
  FD_CLOSE        = $20;
  FD_QOS          = $40;
  FD_GROUP_QOS    = $80;
  FD_MAX_EVENTS = 8;
  FD_ALL_EVENTS = $100; { AHS - trudno powiedzie? ile powinno by?}
{ All Windows Sockets error constants are biased by WSABASEERR from the "normal" }
  WSABASEERR              = 10000;
{ Windows Sockets definitions of regular Microsoft C error constants }
  WSAEINTR                = (WSABASEERR+4);
  WSAEBADF                = (WSABASEERR+9);
  WSAEACCES               = (WSABASEERR+13);
  WSAEFAULT               = (WSABASEERR+14);
  WSAEINVAL               = (WSABASEERR+22);
  WSAEMFILE               = (WSABASEERR+24);
{ Windows Sockets definitions of regular Berkeley error constants }
  WSAEWOULDBLOCK          = (WSABASEERR+35);
  WSAEINPROGRESS          = (WSABASEERR+36);
  WSAEALREADY             = (WSABASEERR+37);
  WSAENOTSOCK             = (WSABASEERR+38);
  WSAEDESTADDRREQ         = (WSABASEERR+39);
  WSAEMSGSIZE             = (WSABASEERR+40);
  WSAEPROTOTYPE           = (WSABASEERR+41);
  WSAENOPROTOOPT          = (WSABASEERR+42);
  WSAEPROTONOSUPPORT      = (WSABASEERR+43);
  WSAESOCKTNOSUPPORT      = (WSABASEERR+44);
  WSAEOPNOTSUPP           = (WSABASEERR+45);
  WSAEPFNOSUPPORT         = (WSABASEERR+46);
  WSAEAFNOSUPPORT         = (WSABASEERR+47);
  WSAEADDRINUSE           = (WSABASEERR+48);
  WSAEADDRNOTAVAIL        = (WSABASEERR+49);
  WSAENETDOWN             = (WSABASEERR+50);
  WSAENETUNREACH          = (WSABASEERR+51);
  WSAENETRESET            = (WSABASEERR+52);
  WSAECONNABORTED         = (WSABASEERR+53);
  WSAECONNRESET           = (WSABASEERR+54);
  WSAENOBUFS              = (WSABASEERR+55);
  WSAEISCONN              = (WSABASEERR+56);
  WSAENOTCONN             = (WSABASEERR+57);
  WSAESHUTDOWN            = (WSABASEERR+58);
  WSAETOOMANYREFS         = (WSABASEERR+59);
  WSAETIMEDOUT            = (WSABASEERR+60);
  WSAECONNREFUSED         = (WSABASEERR+61);
  WSAELOOP                = (WSABASEERR+62);
  WSAENAMETOOLONG         = (WSABASEERR+63);
  WSAEHOSTDOWN            = (WSABASEERR+64);
  WSAEHOSTUNREACH         = (WSABASEERR+65);
  WSAENOTEMPTY            = (WSABASEERR+66);
  WSAEPROCLIM             = (WSABASEERR+67);
  WSAEUSERS               = (WSABASEERR+68);
  WSAEDQUOT               = (WSABASEERR+69);
  WSAESTALE               = (WSABASEERR+70);
  WSAEREMOTE              = (WSABASEERR+71);
{ Extended Windows Sockets error constant definitions }
  WSASYSNOTREADY          = (WSABASEERR+91);
  WSAVERNOTSUPPORTED      = (WSABASEERR+92);
  WSANOTINITIALISED       = (WSABASEERR+93);
  WSAEDISCON              = (WSABASEERR+101);
  WSAENOMORE              = (WSABASEERR+102);
  WSAECANCELLED           = (WSABASEERR+103);
  WSAEEINVALIDPROCTABLE   = (WSABASEERR+104);
  WSAEINVALIDPROVIDER     = (WSABASEERR+105);
  WSAEPROVIDERFAILEDINIT  = (WSABASEERR+106);
  WSASYSCALLFAILURE       = (WSABASEERR+107);
  WSASERVICE_NOT_FOUND    = (WSABASEERR+108);
  WSATYPE_NOT_FOUND       = (WSABASEERR+109);
  WSA_E_NO_MORE           = (WSABASEERR+110);
  WSA_E_CANCELLED         = (WSABASEERR+111);
  WSAEREFUSED             = (WSABASEERR+112);
{ Error return codes from gethostbyname() and gethostbyaddr()
  (when using the resolver). Note that these errors are
  retrieved via WSAGetLastError() and must therefore follow
  the rules for avoiding clashes with error numbers from
  specific implementations or language run-time systems.
  For this reason the codes are based at WSABASEERR+1001.
  Note also that [WSA]NO_ADDRESS is defined only for
  compatibility purposes. }
{ Authoritative Answer: Host not found }
  WSAHOST_NOT_FOUND       = (WSABASEERR+1001);
  HOST_NOT_FOUND          = WSAHOST_NOT_FOUND;
{ Non-Authoritative: Host not found, or SERVERFAIL }
  WSATRY_AGAIN            = (WSABASEERR+1002);
  TRY_AGAIN               = WSATRY_AGAIN;
{ Non recoverable errors, FORMERR, REFUSED, NOTIMP }
  WSANO_RECOVERY          = (WSABASEERR+1003);
  NO_RECOVERY             = WSANO_RECOVERY;
{ Valid name, no data record of requested type }
  WSANO_DATA              = (WSABASEERR+1004);
  NO_DATA                 = WSANO_DATA;
{ no address, look for MX record }
  WSANO_ADDRESS           = WSANO_DATA;
  NO_ADDRESS              = WSANO_ADDRESS;
{ Windows Sockets errors redefined as regular Berkeley error constants.
  These are commented out in Windows NT to avoid conflicts with errno.h.
  Use the WSA constants instead. }
  EWOULDBLOCK        =  WSAEWOULDBLOCK;
  EINPROGRESS        =  WSAEINPROGRESS;
  EALREADY           =  WSAEALREADY;
  ENOTSOCK           =  WSAENOTSOCK;
  EDESTADDRREQ       =  WSAEDESTADDRREQ;
  EMSGSIZE           =  WSAEMSGSIZE;
  EPROTOTYPE         =  WSAEPROTOTYPE;
  ENOPROTOOPT        =  WSAENOPROTOOPT;
  EPROTONOSUPPORT    =  WSAEPROTONOSUPPORT;
  ESOCKTNOSUPPORT    =  WSAESOCKTNOSUPPORT;
  EOPNOTSUPP         =  WSAEOPNOTSUPP;
  EPFNOSUPPORT       =  WSAEPFNOSUPPORT;
  EAFNOSUPPORT       =  WSAEAFNOSUPPORT;
  EADDRINUSE         =  WSAEADDRINUSE;
  EADDRNOTAVAIL      =  WSAEADDRNOTAVAIL;
  ENETDOWN           =  WSAENETDOWN;
  ENETUNREACH        =  WSAENETUNREACH;
  ENETRESET          =  WSAENETRESET;
  ECONNABORTED       =  WSAECONNABORTED;
  ECONNRESET         =  WSAECONNRESET;
  ENOBUFS            =  WSAENOBUFS;
  EISCONN            =  WSAEISCONN;
  ENOTCONN           =  WSAENOTCONN;
  ESHUTDOWN          =  WSAESHUTDOWN;
  ETOOMANYREFS       =  WSAETOOMANYREFS;
  ETIMEDOUT          =  WSAETIMEDOUT;
  ECONNREFUSED       =  WSAECONNREFUSED;
  ELOOP              =  WSAELOOP;
  ENAMETOOLONG       =  WSAENAMETOOLONG;
  EHOSTDOWN          =  WSAEHOSTDOWN;
  EHOSTUNREACH       =  WSAEHOSTUNREACH;
  ENOTEMPTY          =  WSAENOTEMPTY;
  EPROCLIM           =  WSAEPROCLIM;
  EUSERS             =  WSAEUSERS;
  EDQUOT             =  WSAEDQUOT;
  ESTALE             =  WSAESTALE;
  EREMOTE            =  WSAEREMOTE;
{ AHS }
{ WinSock 2 extension -- new error codes and type definition }
type
  WSAEVENT                = THANDLE;
  LPHANDLE                = PHANDLE;
  LPWSAEVENT              = LPHANDLE;
  WSAOVERLAPPED           = TOVERLAPPED;
  LPWSAOVERLAPPED         = POverlapped;
const
  WSA_IO_PENDING          = ERROR_IO_PENDING;
  WSA_IO_INCOMPLETE       = ERROR_IO_INCOMPLETE;
  WSA_INVALID_HANDLE      = ERROR_INVALID_HANDLE;
  WSA_INVALID_PARAMETER   = ERROR_INVALID_PARAMETER;
  WSA_NOT_ENOUGH_MEMORY   = ERROR_NOT_ENOUGH_MEMORY;
  WSA_OPERATION_ABORTED   = ERROR_OPERATION_ABORTED;
  WSA_INVALID_EVENT       = WSAEVENT(NiL);
  WSA_MAXIMUM_WAIT_EVENTS = MAXIMUM_WAIT_OBJECTS;
  WSA_WAIT_FAILED         = DWORD($FFFFFFFF); { ahs }
  WSA_WAIT_EVENT_0        = WAIT_OBJECT_0;
  WSA_WAIT_IO_COMPLETION  = WAIT_IO_COMPLETION;
  WSA_WAIT_TIMEOUT        = WAIT_TIMEOUT;
  WSA_INFINITE            = INFINITE;
{ WinSock 2 extension -- WSABUF and QOS struct }
type
PWSABUF = ^TWSABUF;
TWSABUF = packed record
  len                : u_long;     { the length of the buffer }
  buf                : Pointer; //PChar;     { the pointer to the buffer }
end;
GUARANTEE = (
    BestEffortService,
    ControlledLoadService,
    PredictiveService,
    GuaranteedDelayService,
    GuaranteedService
);
PFlowspec = ^TFlowspec;
TFlowspec = packed record
  TokenRate             : LongInt;        { In Bytes/sec }
  TokenBucketSize       : LongInt;        { In Bytes }
  PeakBandwidth         : LongInt;        { In Bytes/sec }
  Latency               : LongInt;        { In microseconds }
  DelayVariation        : LongInt;        { In microseconds }
  LevelOfGuarantee      : Guarantee;      { Guaranteed, Predictive }
                                          { or Best Effort       }
  CostOfCall            : LongInt;        { Reserved for future use, }
                                          { must be set to 0 now   }
  NetworkAvailability   : LongInt;        { read-only:         }
                                          {   1 if accessible, }
                                          {   0 if not         }
end;
PQOS = ^TQualityOfService;
TQualityOfService = packed record
  SendingFlowspec       :TFlowspec;    { the flow spec for data sending }
  ReceivingFlowspec     :TFlowspec;    { the flow spec for data receiving }
  ProviderSpecific      :TWSABuf;      { additional provider specific stuff }
end;
const
{ WinSock 2 extension -- manifest constants for return values of the
  condition function}
  CF_ACCEPT       = $0000;
  CF_REJECT       = $0001;
  CF_DEFER        = $0002;
{WinSock 2 extension -- manifest constants for shutdown() }
  SD_RECEIVE      = $00;
  SD_SEND         = $01;
  SD_BOTH         = $02;
{ WinSock 2 extension -- data type and manifest constants for socket groups }
type
  TGroup            = u_int;
  PGroup           = ^TGroup;
const
 
  SG_UNCONSTRAINED_GROUP   = $01;
  SG_CONSTRAINED_GROUP     = $02;
{ WinSock 2 extension -- data type for WSAEnumNetworkEvents() }
type
PWSANETWORKEVENTS = ^TWSANETWORKEVENTS;
TWSANETWORKEVENTS = packed record
  lNetworkEvents           :u_long;
  iErrorCode               : array [0..FD_MAX_EVENTS-1] of u_int;
end;
{WinSock 2 extension -- WSAPROTOCOL_INFO structure and associated
 manifest constants}
PGUID = ^TGUID;
TGUID = packed record
  Data1              :u_long;
  Data2              :u_short;
  Data3              :u_short;
  Data4              : array [0..8-1] of u_char;
end;
const
  MAX_PROTOCOL_CHAIN  = 7;
  BASE_PROTOCOL       = 1;
  LAYERED_PROTOCOL    = 0;
type
PWSAPROTOCOLCHAIN = ^TWSAPROTOCOLCHAIN;
TWSAPROTOCOLCHAIN = packed record
  ChainLen        : Integer;            { the length of the chain,     }
                                        { length = 0 means layered protocol, }
                                        { length = 1 means base protocol, }
                                        { length > 1 means protocol chain }
  ChainEntries : array[0..MAX_PROTOCOL_CHAIN-1] of DWORD; { a list of dwCatalogEntryIds }
end;
const
  WSAPROTOCOL_LEN    = 255;
type
 
PWSAPROTOCOL_INFOA = ^TWSAPROTOCOL_INFOA;
TWSAPROTOCOL_INFOA = packed record
  dwServiceFlags1           : DWORD;
  dwServiceFlags2           : DWORD;
  dwServiceFlags3           : DWORD;
  dwServiceFlags4           : DWORD;
  dwProviderFlags           : DWORD;
  ProviderId                : TGUID;
  dwCatalogEntryId          : DWORD;
  ProtocolChain             : TWSAPROTOCOLCHAIN;
  iVersion                  : u_int;
  iAddressFamily            : u_int;
  iMaxSockAddr              : u_int;
  iMinSockAddr              : u_int;
  iSocketType               : u_int;
  iProtocol                 : u_int;
  iProtocolMaxOffset        : u_int;
  iNetworkByteOrder         : u_int;
  iSecurityScheme           : u_int;
  dwMessageSize            : DWORD;
  dwProviderReserved       : DWORD;
  szProtocol               : array [0..WSAPROTOCOL_LEN+1-1] of u_char;
end;

[浏览: 次]   
上一篇:delphi winsock2 网络编程(上)   下一篇:delphi winsock2 网络编程(下)
[收藏] [推荐] [返回顶部] [打印本页] [关闭窗口]  
    评论加载中…
google adsense热点文章
·delphi winsock2 网络编程(下下)
·delphi winsock2 网络编程(上)
·delphi Winsock的传输的API封装
·delphi 多线程技术在Delphi数据库编程
·delphi winsock2 网络编程(下)
·delphi Delphi_转载:TThread类剖析
·delphi Delphi_进程间传递消息(发送和
·delphi 利用线程FTP上传上个目录指定的
·delphi Delphi_获取其他线程的光标句柄
·delphi Smart threads with a central
     delphi技术网 | firefox 下载 | Avant Browser下载 | dedecms 技术网 | drupal 爱好者 | php 技术网
  Copyright@www.delphichm.com,2006-2009.All Rights Reserved.
 
程序员联盟 | delphi Java .net|QQ:707102932