WSockets version 1.20 - Delphi 2.0 WinSocket Classes, a short reference

Страницы работы

Фрагмент текста работы

WSockets version 1.20 - Delphi 2.0 WinSocket Classes, a short reference.

Some helper types and classes:

TSocketState = (ssNotStarted, ssClosed, ssConnected, ssListening, ssOpen);

TOnError = procedure (Sender: TObject; Error: integer; Msg: string) of object;

TOnData = procedure (Sender: TObject; Socket: TSocket) of object;

TOnAccept = procedure (Sender: TObject; Socket: TSocket) of object;

TOnConnect = procedure (Sender: TObject; Socket: TSocket) of object;

TOnClose = procedure (Sender: TObject; Socket: TSocket) of object;

TClientList = class (TObject)

function IndexOf(Socket: TSocket): integer;

property Sockets[Index: integer]: TSocket; default;

property Count: integer;

end;

Generic properties, methods and events available from all classes:

Properties:

Version: string;

The version of the Windows Sockets specification that DLL is using.

Description: string;

A description of the Windows Sockets implementation, including vendor identification.

SystemStatus: string;

Windows Sockets DLL relevant status or configuration information.

MaxSockets: integer;

The maximum number of sockets which a single process can potentially open.

MaxUDPSize: integer;

The size in bytes of the largest UDP datagram that can be sent or received by the application.

LocalSocket: TSocket;

The local communication end point (TTCPServer is listening on this socket).

SocketState: TSocketState;

The state of the LocalSocket:

·  ssNotStarted = Winsock.dll not started.

·  ssClosed = Not opened or connected.

·  ssConnected = TTCPClient connected.

·  ssListening = TTCPServer or TUDPServer is listening.

·  ssOpen = TTCPClient trying to connect or TUDPClient opened.

LastError: integer;

Last error reported from the Windows Socket DLL (a value of zero indicates no error).

LocalHostAddress: string;

The local host address in the form "nnn.nnn.nnn.nnn".

LocalHostName: string;

The local host name assigned to this host.

Methods:

Create (AOwner: TComponent); override;

The class constructor.

GetSockAddrIn (Host, Port: string; var SockAddrIn: TSockAddrIn): boolean;

Constructs a valid Socket Address Internet Style for a given Host and Port.

GetAnySockAddrIn (Port: string; var SockAddrIn: TSockAddrIn): boolean;

Constructs a valid Socket Address Internet Style for a given Port and any Host.

GetBroadcastSockAddrIn (Port: string; var SockAddrIn: TSockAddrIn): boolean;

Constructs a valid Socket Address Internet Style for a given Port with a broadcast address.

SockAddrInToName (SockAddrIn: TSockAddrIn): string;

Returns the Host Name of a valid Socket Address Internet Style.

SockAddrInToAddress (SockAddrIn: TSockAddrIn): string;

Returns the Host Address of a valid Socket Address Internet Style.

SockAddrInToPort (SockAddrIn: TSockAddrIn): string;

Returns the Port of a valid Socket Address Internet Style.

SocketToName (Socket: TSocket): string;

Returns the Host Name of a valid Socket.

SocketToAddress (Socket: TSocket): string;

Returns the Host Address of a valid Socket.

SocketToPort (Socket: TSocket): string;

Returns the Port of a valid Socket.

PeerToName (Socket: TSocket): string;

Returns the Peer Host Name of a valid Socket.

PeerToAddress (Socket: TSocket): string;

Returns the Peer Host Address of a valid Socket.

PeerToPort (Socket: TSocket): string;

Returns the Peer Port of a valid Socket.

Events:

OnError: TOnError (Sender: TObject; Error: integer; Msg: string);

Signals an error where Error is the error code and Msg is the error description.

TTCPClient

Properties:

Handle: HWND;

The Window Handle, may be used in Windows API function calls that requires a handle.

PeerAddress: string;

The IP-address of the peer partner.

PeerPort: string;

The port used by the peer partner.

Host: string;

Host name or address to connect to.

Port: string;

The port name or number to connect to.

Methods:

Open;

Try to open a connection to Host on Port.

Close;

Close a open connection.

Peek: string;

Peek the incoming data buffer.

Write (Data: string);

Write data to connected partner.

Read: string;

Read data from connected partner.

WriteBuffer (Buffer: Pointer; Size: integer): integer;

Write a data buffer to connected partner.

ReadBuffer (Buffer: Pointer; Size: integer): integer;

Read a data buffer from connected partner.

Events:

OnData: TOnData (Sender: TObject; Socket: TSocket);

Signals incoming data (Socket is the LocalSocket in this case).

OnConnect: TOnConnect (Sender: TObject; Socket: TSocket);

Signals an accepted connection by the server (Socket is the LocalSocket in this case).

OnClose: TOnClose (Sender: TObject; Socket: TSocket);

Signals connection closed by the server (Socket is the LocalSocket

Похожие материалы

Информация о работе

Тип:
Дополнительные материалы
Размер файла:
36 Kb
Скачали:
0