Difference between revisions of "TWSocketServer"

From Overbyte
Jump to navigation Jump to search
Line 84: Line 84:
  
 
{|
 
{|
| width="130" valign="top" | [[TWSocketServer.OnBgException | OnBgException]] |||| Align test
+
| width="130" valign="top" | [[TWSocketServer.OnBgException | OnBgException]] |||| When a background exception occurs.
 
|-
 
|-
| valign="top" | [[TWSocketServer.OnChangeState | OnChangeState]] ||||
+
| valign="top" | [[TWSocketServer.OnChangeState | OnChangeState]] |||| When the component state change.
 
|-
 
|-
| valign="top" | [[TWSocketServer.OnClientConnect | OnClientConnect]] ||||
+
| valign="top" | [[TWSocketServer.OnClientConnect | When a new client is connecting.OnClientConnect]] ||||
 
|-
 
|-
| valign="top" | [[TWSocketServer.OnClientCreate | OnClientCreate]] ||||
+
| valign="top" | [[TWSocketServer.OnClientCreate | OnClientCreate]] |||| When a new client component instance is created.
 
|-
 
|-
| valign="top" | [[TWSocketServer.OnClientDisconnect | OnClientDisconnect]] ||||
+
| valign="top" | [[TWSocketServer.OnClientDisconnect | OnClientDisconnect]] |||| When a client disconnect.
 
|-
 
|-
| valign="top" | [[TWSocketServer.OnError | OnError]] ||||
+
| valign="top" | [[TWSocketServer.OnError | OnError]] |||| When an error occur. Better to use exception handling.
 
|-
 
|-
| valign="top" | [[TWSocketServer.OnMessagePump | OnMessagePump]] ||||
+
| valign="top" | [[TWSocketServer.OnMessagePump | OnMessagePump]] |||| To call your own external message pump instead of built-in one.
 
|}
 
|}
  

Revision as of 15:22, 28 February 2006

Main page -> ICS component reference -> TWSocketServer

Overview

unit WSocketS.pas
inheritance TWSocket

TWSocketServer will normally be used to listen on a given tcp port. When a client connect, it will instanciate a new TWSocketClient component to handle communication with client. Normally you will derive your own component from TWSocketClient to add private data and methods to handle your processing needs. You tell TWSocketServer which component class it has to instanciate using ClientClass property. You have to initialize each instances created to handle each client from OnClientConnect event handler. TWSocketServer maintain a list of connected clients. You can access it using Client[] indexed property. ClientCount property is the size of Client[] array.

Since it is derived from TWSocket, lots of properties and events are unused and not listed here. Properties and events that have a meaning in both server or client component are listed here.

Note that TWSocketServer is only usable for incoming TCP connections. Use TWSocket if you need use UDP.

Properties

Addr The interface to listen on.
Banner A short message line sent when client connect.
BannerTooBusy A short message sent when client connect and number of client already exceed MaxClients limit.
Client Indexed property giving access to all connected clients.
ClientClass Class the component use to handle each incomming connection.
ClientCount Number of connected clients.
Handle Handle of the hidden window used for socket operation.
HSocket Underlaying winsock socket handle.
LastError Last error occured.
ListenBacklog How many pending connection the system has to accept before denying access.
MaxClients Max number of connected client. All subsequent connections will be closed.
Port TCP port or service name to listen to.
PortNum Readonly property with numeric value corresponding to Port.
Proto Protocol used. Must be 'tcp'.
State Gives the satet of the component.

Methods

Abort Abort current asynchronous operation.
Close Close connection.
CloseDelayed Close connection after the current event is finished.
Create Create a new instance of the component.
Destroy Destroy the current instance.
IsClient Check if a component reference is one of the connected clients.
Listen Start accepting connections.
MessageLoop Internal message loop.
MessagePump Internal message pump.
ProcessMessage Process a single message.
ProcessMessages Process messages until message queue is empty.
Release Destroy the current instance after the current event is terminated.
ThreadAttach Detach from current thread.
ThreadDetach Attach to current thread.

Events

OnBgException When a background exception occurs.
OnChangeState When the component state change.
When a new client is connecting.OnClientConnect
OnClientCreate When a new client component instance is created.
OnClientDisconnect When a client disconnect.
OnError When an error occur. Better to use exception handling.
OnMessagePump To call your own external message pump instead of built-in one.

How to



ICS Components Reference