event OnSessionAvailable (Sender: TObject; ErrCode: Word);
OnSessionAvailable is raised everytime a client wants to connect to the IP and Port a certain TCP-Server is listening on.
For UDP-connections this is not needed and should not be used.
The following example implements the OnSessionAvailable of a simple TCP-Server which transfers the accepted connection to another socket so that other incomming connections can be accepted as well. Since the socket the connection is transfered to is a global variable here only one connection can be accepted, but this example is simply for showing the basics.
var socket:TMySocket; // a descendant of TWSocket with overwritten OnDataAvailable procedure TMyServer.MyOnSessionAvailable(Sender: TObject; ErrCode: Word); var NewS:TSocket; begin if ErrCode <> 0 then exit; NewS:=Accept; socket:=TMySocket.create(nil); socket.dup(NewS); end;