TTCPSocket

From Ultibo.org
Jump to: navigation, search

Return to Unit TCP


Description


To be documented

Class definitions



TTCPSocket = class(TProtocolSocket)

Note: SOCK_STREAM
 
constructor Create(AProtocol:TNetworkProtocol; ATransport:TNetworkTransport);  
destructor Destroy; override;  
private
FBackLog:Integer; Backlog size of Listen/Accept Queue
FListener:TProtocolSocket; The Listener socket for this socket (If applicable)
FAcceptQueue:TSocketList; Sockets waiting for connection Accept
FReceiveQueue:TSocketList; Sockets waiting for SYN/ACK handshake
 
FSendData:TTCPSendBuffer;  
FRecvData:TTCPRecvBuffer;  
 
procedure SetBackLog(ABackLog:Integer);  
procedure SetListener(AListener:TProtocolSocket);  
public
property BackLog:Integer read FBackLog write SetBackLog;  
property Listener:TProtocolSocket read FListener write SetListener;  
property AcceptQueue:TSocketList read FAcceptQueue;  
property ReceiveQueue:TSocketList read FReceiveQueue;  
 
property SendData:TTCPSendBuffer read FSendData;  
property RecvData:TTCPRecvBuffer read FRecvData;  
 
function GetOption(ALevel,AOptName:Integer; AOptValue:PChar; var AOptLength:Integer):Integer; override;  
function SetOption(ALevel,AOptName:Integer; AOptValue:PChar; AOptLength:Integer):Integer; override;  
function IoCtl(ACommand:DWORD; var AArgument:u_long):Integer; override;  
 
function IsConnected(ALocalAddress,ARemoteAddress:Pointer; ALocalPort,ARemotePort:Word; ABroadcast:Boolean):Boolean; override;  
function IsListening(ALocalAddress,ARemoteAddress:Pointer; ALocalPort,ARemotePort:Word; ABroadcast:Boolean):Boolean; override;  
 
function Listen:Boolean;  
function Connect:Boolean;  
function Reconnect:Boolean;  
function Disconnect:Boolean;  
 
function Accept(APeek,ALock:Boolean; AState:LongWord):TTCPSocket;  
 
function RecvSegment(ASequence,AAcknowledge:LongWord; AWindow,AUrgent:Word; AFlags:Byte; AData:Pointer; ASize:Word):Boolean;  
function SendSegment(var ASequence,AAcknowledge:LongWord; var AWindow,AUrgent:Word; var AFlags:Byte; var AData:Pointer; var ASize:Word):Boolean;  


Function declarations



constructor TTCPSocket.Create(AProtocol:TNetworkProtocol; ATransport:TNetworkTransport);
Description: To be documented
Note None documented


destructor TTCPSocket.Destroy;
Description: To be documented
Note None documented


procedure TTCPSocket.SetBackLog(ABackLog:Integer);
Description: To be documented
Note None documented


procedure TTCPSocket.SetListener(AListener:TProtocolSocket);
Description: To be documented
Note None documented


function TTCPSocket.GetOption(ALevel,AOptName:Integer; AOptValue:PChar; var AOptLength:Integer):Integer;
Description: To be documented
Note With Socket Options that are Boolean 0 is False and > 0 is True


function TTCPSocket.SetOption(ALevel,AOptName:Integer; AOptValue:PChar; AOptLength:Integer):Integer;
Description: To be documented
Note With Socket Options that are Boolean 0 is False and > 0 is True


function TTCPSocket.IoCtl(ACommand:DWORD; var AArgument:u_long):Integer;
Description: To be documented
Note None documented


function TTCPSocket.IsConnected(ALocalAddress,ARemoteAddress:Pointer; ALocalPort,ARemotePort:Word; ABroadcast:Boolean):Boolean;
Description: Check if this TCP Socket is Connected to the Host specified by RemoteAddress/Port
Note A connected Socket will have a Bound LocalAddress/Port and a Connected RemoteAddress/Port


function TTCPSocket.IsListening(ALocalAddress,ARemoteAddress:Pointer; ALocalPort,ARemotePort:Word; ABroadcast:Boolean):Boolean;
Description: Check if this TCP Socket is Listening on the LocalAddress/Port specified
Note A listening Socket may or may not have a Bound LocalAddress/Port and will have a default (INADDR_ANY/IPPORT_ANY) RemoteAddress/Port


function TTCPSocket.Listen:Boolean;
Description: Used by Listen to setup the listening state
Note Initiate listening for connections


function TTCPSocket.Connect:Boolean;
Description: Used by Connect to initiate outbound connection and Used by RecvSegment to respond to inbound connection
Note Initiate a connection handshake (SYN/SYNACK/ACK)


function TTCPSocket.Reconnect:Boolean;
Description: Used by Connect to retry outbound connection
Note Retry the connection handshake (SYN/SYNACK/ACK)


function TTCPSocket.Disconnect:Boolean;
Description: Used by CloseSocket/Shutdown to terminate outbound connection
Note Initiate a disconnection handshake (FIN/ACK)


function TTCPSocket.Accept(APeek,ALock:Boolean; AState:LongWord):TTCPSocket;
Description: Used by Accept/Select to receive an inbound connection
Note Return the first Connected socket in the Accept Queue


function TTCPSocket.RecvSegment(ASequence,AAcknowledge:LongWord; AWindow,AUrgent:Word; AFlags:Byte; AData:Pointer; ASize:Word):Boolean;
Description: Used by Segment Handler to feed segments/acks to the Buffers
Note ACK/SEQ have passed initial check by the Segment Handler

Flags have passed a validity check by the Segment Handler
Size can be zero, Data will then point to invalid or nil
State transition and simultaneous Connect are done here


function TTCPSocket.SendSegment(var ASequence,AAcknowledge:LongWord; var AWindow,AUrgent:Word; var AFlags:Byte; var AData:Pointer; var ASize:Word):Boolean;
Description: Used by Process Socket to get segments/acks for Sending
Note Size can return zero and Data can return nil


Return to Unit Reference