Unit GWinsock

Classes

Functions

accept - prototypes for WINSOCK.
bind -
closesocket -
connect -
gethostbyaddr -
gethostbyname -
gethostname -
getpeername -
getprotobyname -
getprotobynumber -
getservbyname -
getservbyport -
getsockname -
getsockopt -
htonl -
htons -
inet_addr -
inet_ntoa -
ioctlsocket -
listen -
ntohl -
ntohs -
recv -
recvfrom -
select -
send -
sendto -
setsockopt -
shutdown -
socket -
WSAAsyncGetHostByAddr -
WSAAsyncGetHostByName -
WSAAsyncGetProtoByName -
WSAAsyncGetProtoByNumber -
WSAAsyncGetServByName -
WSAAsyncGetServByPort -
WSAAsyncSelect -
WSACancelAsyncRequest -
WSACancelBlockingCall -
WSACleanup -
WSAGetLastError -
WSAIsBlocking -
WSASetBlockingHook -
WSASetLastError -
WSAStartup -
WSAUnhookBlockingHook -

Types

PHostInfo
PInteger
PLongInt
PPChar
PPLongInt
PProtocolInfo
PServerInfo
PSocketAddress
PSocketList
PTimeValue
PWSAData
TErrorMessage
THostInfo
TProtocolInfo
TServerInfo
TSocketAddress
TSocketList
TTimeValue
TWSAData

Constants

AF_INET
FD_ACCEPT
FD_ALL
FD_CLOSE
FD_CONNECT
FD_OOB
FD_READ
FD_WRITE
INADDR_ANY
INVALID_SOCKET
IPPROTO_GGP
IPPROTO_ICMP
IPPROTO_IDP
IPPROTO_IP
IPPROTO_MAX
IPPROTO_ND
IPPROTO_PUP
IPPROTO_RAW
IPPROTO_TCP
IPPROTO_UDP
MAXGETHOSTSTRUCT
MsgAsyncEvent
MsgHostInfoReady
MsgServerInfoReady
SHUTDOWN_BOTH
SHUTDOWN_RECV
SHUTDOWN_SEND
SOCKET_ERROR
SOCK_DGRAM
SOCK_STREAM
SO_ACCEPTCONN
SO_BROADCAST
SO_DEBUG
SO_DONTLINGER
SO_DONTROUTE
SO_ERROR
SO_KEEPALIVE
SO_LINGER
SO_OOBINLINE
SO_RCVBUF
SO_RCVLOWAT
SO_RCVTIMEO
SO_REUSEADDR
SO_SNDBUF
SO_SNDLOWAT
SO_SNDTIMEO
SO_TYPE
SO_USELOOPBACK
WinsockMessage

Variables


Functions


function accept(Socket: THandle; Address: PSocketAddress; Size: Integer): Integer;

prototypes for WINSOCK.DLL functions listed alphabetically

external directives WINSOCK.DLL routines listed by index number


function bind(Socket: THandle; Address: PSocketAddress; Size: Integer): Integer;


function closesocket(Socket: THandle): Integer;


function connect(Socket: THandle; Address: PSocketAddress; Size: Integer): Integer;


function gethostbyaddr(Address: PLongInt; Size: Integer; AddressFamily: Integer): PHostInfo;


function gethostbyname(Name: PChar): PHostInfo;


function gethostname(Name: PChar; Size: Integer): Integer;


function getpeername(Socket: THandle; Peer: PSocketAddress; Size: PInteger): Integer;


function getprotobyname(Name: PChar): PProtocolInfo;


function getprotobynumber(ProtocolID: Integer): PProtocolInfo;


function getservbyname(Name: PChar; Protocol: PChar): PServerInfo;


function getservbyport(Port: Integer; Protocol: PChar): PServerInfo;


function getsockname(Socket: THandle; Address: PSocketAddress; Size: PInteger): Integer;


function getsockopt(Socket: THandle; Level: Integer; OptionFlag: Integer; OptionValue: PChar; Size: PInteger): Integer;


function htonl(Address: LongInt): LongInt;


function htons(Address: Integer): Integer;


function inet_addr(IP: PChar): LongInt;


function inet_ntoa(Address: LongInt): PChar;


function ioctlsocket(Socket: THandle; Command: LongInt; var Argument): Integer;


function listen(Socket: THandle; BackLog: Integer): Integer;


function ntohl(Address: LongInt): LongInt;


function ntohs(Address: Integer): Integer;


function recv(Socket: THandle; Buffer: PChar; Size: Integer; Flags: Integer): Integer;


function recvfrom(Socket: THandle; Buffer: PChar; Size: Integer; Flags: Integer; Address: PSocketAddress; Size: PInteger): Integer;


function select(Unused: Integer; ReadList: PSocketList; WriteList: PSocketList; CheckList: PSocketList; TimeOut: PTimeValue): LongInt;


function send(Socket: THandle; Buffer: PChar; Size: Integer; Flags: Integer): Integer;


function sendto(Socket: THandle; Buffer: PChar; Size: Integer; Flags: Integer; Address: PSocketAddress; AddressSize: Integer): Integer;


function setsockopt(Socket: THandle; Level: Integer; OptionFlag: Integer; NewValue: PChar; Size: Integer): Integer;


function shutdown(Socket: THandle; Options: Integer): Integer;


function socket(AddressFormat: Integer; SocketType: Integer; Protocol: Integer): Integer;


function WSAAsyncGetHostByAddr(Window: HWnd; Msg: Word; Address: PLongInt; Size: Integer; ProtocolFamily: Integer; Host: PHostInfo; Size: Integer): THandle;


function WSAAsyncGetHostByName(Window: HWnd; Msg: Word; Name: PChar; Host: PHostInfo; Size: Integer): THandle;


function WSAAsyncGetProtoByName(Window: HWnd; Msg: Word; ProtocolName: PChar; Protocol: PProtocolInfo; Size: Integer): THandle;


function WSAAsyncGetProtoByNumber(Window: HWnd; Msg: Word; ProtocolID: Integer; Protocol: PProtocolInfo; Size: Integer): THandle;


function WSAAsyncGetServByName(Window: HWnd; Msg: Word; ServiceName: PChar; ProtocolName: PChar; Server: PServerInfo; Size: Integer): THandle;


function WSAAsyncGetServByPort(Window: HWnd; Msg: Word; Port: Integer; ProtocolName: PChar; Server: PServerInfo; Size: Integer): THandle;


function WSAAsyncSelect(Socket: THandle; Window: HWnd; Msg: Word; Event: LongInt): Integer;


function WSACancelAsyncRequest(TaskHandle: THandle): Integer;


function WSACancelBlockingCall: Integer;


function WSACleanup: Integer;


function WSAGetLastError: Integer;


function WSAIsBlocking: Boolean;


function WSASetBlockingHook(BlockingFunction: TFarProc): TFarProc;


procedure WSASetLastError(ErrorCode: Integer);


function WSAStartup(Version: Word; WSDataAddr: PWSAData): Integer;


function WSAUnhookBlockingHook: Integer;


Types


PHostInfo      = ^THostInfo

PInteger       = ^Integer

PLongInt       = ^LongInt

PPChar         = ^PChar
new basic pointer types
PPLongInt      = ^PLongInt

PProtocolInfo  = ^TProtocolInfo

PServerInfo    = ^TServerInfo

PSocketAddress = ^TSocketAddress

PSocketList    = ^TSocketList

PTimeValue     = ^TTimeValue

PWSAData       = ^TWSAData
new WINSOCK pointer types
TErrorMessage = record
ErrorCode : Integer;
Text : string[50];
end;
special type for WINSOCK error table
THostInfo = record
Name : PChar;
AliasList : PPChar;
AddressType : Integer;
AddressSize : Integer;
AddressList : PPLongInt;
Reserved : array[1..MAXGETHOSTSTRUCT] of char;
end;

TProtocolInfo = record
Name : PChar;
Aliases : PPChar;
ProtocolID : Integer;
Reserved : array[1..MAXGETHOSTSTRUCT] of char;
end;

TServerInfo = record
Name : PChar;
Aliases : PPChar;
Port : Integer;
Protocol : PChar;
Reserved : array[1..MAXGETHOSTSTRUCT] of char;
end;

TSocketAddress = record
Family : Integer;
Port : Word;
Address : LongInt;
Unused : array[1..8] of char;
end;

TSocketList = record
Count : Integer;
DescriptorList : array[1..64] of Integer;
end;

TTimeValue = record
Sec : LongInt;
uSec : LongInt;
end;

TWSAData = record
Version : Word;
HighVersion : Word;
Description : array [0..256] of char;
Status : array [0..128] of char;
MaxSockets : Word;
MaxUdpDatagramSize : Word;
VendorInfo : PChar;
end;
record types used by WINSOCK functions

Constants

AF_INET = 2

other WINSOCK constants

FD_ACCEPT = 8

FD_ALL = 63

FD_CLOSE = 32

FD_CONNECT = 16

FD_OOB = 4

FD_READ = 1

event bitflags defined in Windows Sockets Specification

FD_WRITE = 2

INADDR_ANY = 0

INVALID_SOCKET = -1

IPPROTO_GGP = 2

IPPROTO_ICMP = 1

IPPROTO_IDP = 22

IPPROTO_IP = 0

protocol ID numbers

IPPROTO_MAX = 256

IPPROTO_ND = 77

IPPROTO_PUP = 12

IPPROTO_RAW = 255

IPPROTO_TCP = 6

IPPROTO_UDP = 17

MAXGETHOSTSTRUCT = 1024

MsgAsyncEvent = WM_USER+2

MsgHostInfoReady = WM_USER+0

new messages for asynchronous callbacks

MsgServerInfoReady = WM_USER+1

SHUTDOWN_BOTH = 2

SHUTDOWN_RECV = 0

SHUTDOWN_SEND = 1

SOCKET_ERROR = -1

SOCK_DGRAM = 2

SOCK_STREAM = 1

socket types currently supported

SO_ACCEPTCONN = 2

SO_BROADCAST = 32

SO_DEBUG = 1

socket option values

SO_DONTLINGER = 65407

SO_DONTROUTE = 16

SO_ERROR = 4103

SO_KEEPALIVE = 8

SO_LINGER = 128

SO_OOBINLINE = 256

SO_RCVBUF = 4098

SO_RCVLOWAT = 4100

SO_RCVTIMEO = 4102

SO_REUSEADDR = 4

SO_SNDBUF = 4097

SO_SNDLOWAT = 4099

SO_SNDTIMEO = 4101

SO_TYPE = 4104

SO_USELOOPBACK = 64

WinsockMessage = ( (ErrorCode:10004; Text:'Interrupted system call'), (ErrorCode:10009; Text:'Bad file number'), (ErrorCode:10013; Text:'Permission denied'), (ErrorCode:10014; Text:'Bad address'), (ErrorCode:10022; Text:'Invalid argument'), (ErrorCode:10024; Text:'Too many open files'), (ErrorCode:10035; Text:'Operation would block'), (ErrorCode:10036; Text:'Operation now in progress'), (ErrorCode:10037; Text:'Operation already in progress'), (ErrorCode:10038; Text:'Socket operation on non-socket'), (ErrorCode:10039; Text:'Destination address required'), (ErrorCode:10040; Text:'Message too long'), (ErrorCode:10041; Text:'Wrong protocol type for socket'), (ErrorCode:10042; Text:'Bad protocol option'), (ErrorCode:10043; Text:'Protocol not supported'), (ErrorCode:10044; Text:'Socket type not supported'), (ErrorCode:10045; Text:'Operation not supported on socket'), (ErrorCode:10046; Text:'Protocol family not supported'), (ErrorCode:10047; Text:'Address family not supported by protocol family'), (ErrorCode:10048; Text:'Address already in use'), (ErrorCode:10049; Text:'Can''t assign requested address'), (ErrorCode:10050; Text:'Network is down'), (ErrorCode:10051; Text:'Network is unreachable'), (ErrorCode:10052; Text:'Network dropped connection or reset'), (ErrorCode:10053; Text:'Software caused connection abort'), (ErrorCode:10054; Text:'Connection reset by peer'), (ErrorCode:10055; Text:'No buffer space available'), (ErrorCode:10056; Text:'Socket is already connected'), (ErrorCode:10057; Text:'Socket is not connected'), (ErrorCode:10058; Text:'Can''t send after socket shutdown'), (ErrorCode:10059; Text:'Too many references, can''t splice'), (ErrorCode:10060; Text:'Connection timed out'), (ErrorCode:10061; Text:'Connection refused'), (ErrorCode:10062; Text:'Too many levels of symbolic links'), (ErrorCode:10063; Text:'File name too long'), (ErrorCode:10064; Text:'Host is down'), (ErrorCode:10065; Text:'No route to Host'), (ErrorCode:10066; Text:'Directory not empty'), (ErrorCode:10067; Text:'Too many processes'), (ErrorCode:10068; Text:'Too many users'), (ErrorCode:10069; Text:'Disc quota exceeded'), (ErrorCode:10070; Text:'Stale NFS file handle'), (ErrorCode:10071; Text:'Too many levels of remote in path'), (ErrorCode:10091; Text:'Network subsystem is unavailable'), (ErrorCode:10092; Text:'Incompatible version of WINSOCK.DLL'), (ErrorCode:10093; Text:'Successful WSAStartup not yet performed'), (ErrorCode:11001; Text:'Host not found'), (ErrorCode:11002; Text:'Non-Authoritative Host not found'), (ErrorCode:11003; Text:'Non-Recoverable error: FORMERR, REFUSED, NOTIMP'), (ErrorCode:11004; Text:'Valid name, no data record of requested type'), (ErrorCode:0; Text:'Unrecognized error code') )

message table - maps WINSOCK error codes to messages strings

Variables