Nagle.
function WriteResultByCode(const Code: Integer;
const Rslt: Array of TBPDXStatusCodeRecord): Integer;
This routine provides many of our protocol implementations with an easy way to return a result code from an memory collection (Array) of our TBPDXStatusCodeRecord, by simply calling this routine with a status code number and passing the built-in Status Code collection.
function WriteResultCode(const Code: Integer;
const Rslt: AnsiString): Integer;
This routine provides many of our protocol implementations with a way to return a abnormal result code and Status Code message. There are times in certain protocols where the default message is not accurate for your current situation. Or the message needs values to be applied, like fsFileName+' not found.'.
function WriteWithSize(Const S:AnsiString): Boolean;
This routine sends a 4 Byte header (Integer 32bit) in reverse Endian (to be compatible with Unix(s)). This is one way of formatting your data, making sure then other end has implemented a similar ReadWithSize() routine.
function WriteInteger(const n: integer): integer;
This routine sends a 4 Byte Integer (32bit) in reverse Endian (to be compatible with Unix(s)).
function WriteIntegerNoEndian(const n: integer): integer;
This routine sends a 4 Byte Integer (32bit) in without reversing the Endian.
function ReceiveBuf(var Buf;Const Count: Integer): Integer;
This routine is provided to make your transition from using the Borland socket implementation to DXSock much easier. It functions exactly like the DXSock read() routine (which you should migrate to using).
function Read(buf: Pointer;Const len: Integer): Integer; overload;
This routine is our low-level read from the socket call. It is pointer based, handles slow reads, encrypted sessions, etc. The return value contains the actual number of bytes read into the buf:pointer.
See also LastReadTimeout, LastCommandStatus and Connected.
function read: char; overload;
This routine is used internally, however, exposed to you incase you need to read a single character from the socket layer.
function ReadInteger: integer;
This routine read a single 32bit Integer from the socket buffer, doing a reverse Endian from Unix(es) to Windows.
function ReadIntegerNoEndian: integer;
This routine read a single 32bit Integer from the socket buffer, does not reverse Endian.
function ReadStr(Const MaxLength: Integer): AnsiString;
This routine provides you with a mechanism to interact with the socket layer as a string instead of using a pointer. It is a wrapper around the standard read routine, thus it also works without a timeout parameter.
function ReadString(Const MaxLength: Integer;
Const Timeout: Longword): AnsiString;
This routine provides you with the mechanism to interact with the socket layer as a string. The primary differences between this routine and ReadStr are MaxLength should be the sizes of the expected packet content (250 bytes is the maximum), and it does not try to receive anything from the socket until the first packet in the socket buffer is equal to or longer than the specified MaxLength. This routine does implement the timeout parameter. This routine was implemented per a customer request, and normally should not be used unless you really understand how this routine works.
function ReadLn(Const Timeout: Longword): AnsiString;
This routine provides you with a mechanism to retrieve data from the socket layer where the line delimiter is either a carriage return, or a line feed, or a combination of carriage return and line feed, or line feed and carriage return. Thus supporting the standard carriage return and line feed delimiter, plus combinations normally associated with UNIX-based clients or Macintosh based clients. This routine does implement the timeout parameter and contains logic to avoid hacker-overrun attacks.
function ReadCRLF(Const Timeout: Longword): AnsiString;
This routine provides you with a mechanism to retrieve data from the socket layer where the line delimiter is carriage return and line feed. There are occasions where this routine is more useful than trying to use the Readln routine, normally when you know the client will only send the carriage return followed by a line feed. This routine does implement the timeout parameter and incorporates logic to avoid hacker-overrun attacks.
function ReadToAnyDelimiter(Const Timeout: Longword;
Const Delimiter: ShortString): AnsiString;
This routine provides you with a mechanism to retrieve data from the socket layer and specify what the line delimiter is.
Note The line delimiter can be any combination of characters. A common mistake is to specify a delimiter that may also be found within the normal data. This routine does implement the timeout parameter and incorporates logic to avoid hacker-overrun attacks.
function ReadNull(Const Timeout: Longword): AnsiString;
This routine provides you with a mechanism to retrieve data from the socket layer where the delimiter is a Null. This routine does implement the timeout parameter and incorporates logic to avoid hacker-overrun attacks.
function ReadSpace(Const Timeout: Longword): AnsiString;
This routine provides you with a mechanism to retrieve data from the socket layer where the delimiter is a Space (#32). This routine does implement the timeout parameter and incorporates logic to avoid hacker-overrun attacks.
function ReadWithSize: AnsiString;
This procedure provides you with a mechanism to retrieve a string of data that has been prefixed with a 4-byte header. It was introduced per a customer request.
function getchar: str1;
This routine works much like the read routine that returns a character except it was designed to return a blank if there was no data or an error instead of #0.
Note Anytime you interact with a socket buffer character-by-character, you will see a severe performance drop. Doing so causes the socket layer to lock its internal buffer to retrieve a single character then release the lock, which means no packet can be handled during these couple of milliseconds, thus producing the severe performance drop.
function getbyte: byte;
This routine works much like the read routine that returns a character except it was designed to return a zero if there was no data or an error.
Note Anytime you interact with a socket buffer byte-by-byte, you will see a severe performance drop. Doing so causes the socket layer to lock its internal buffer to retrieve a single byte then release the lock, which means no packet can be handled during these couple of milliseconds, thus producing the severe performance drop.
function PeekString: AnsiString;
This routine provides a mechanism that allows you to see the next unread packet of up to 250 characters in the socket layer.
function PeekChar: Char;
This routine provides a mechanism that allows you to see the next unread character of the next packet in the socket layer.
function GetErrorStr: ShortString;
This routine provides you with a mechanism to access the socket layer for a verbal description of the command status. Since TBPDXSock encapsulates the procedural design of the socket layer, it is better to use the GetErrorDesc method with LastCommandStatus.
function GetErrorDesc(Const errorCode: Integer): ShortString;
This routine provides you with the mechanism to access the verbal description of the specified error code. The verbalized string contains the localized text associated with the specified error code. Localization is controlled by a compiler definition in the DXSOCK6.PAS file.
procedure SetNagle(Const TurnOn: Boolean);
This routine provides a mechanism for toggling the Nagel algorithm on or off for the socket layer.
procedure SetBlocking(Const TurnOn: Boolean);
This routine provides a mechanism for toggling blocking for non-blocking socket calls. Blocking mode waits until the socket layer has processed your command/request before returning control back to DXSock and you.
procedure SocketVersion(var SocketInfo: PBPDXSocketInfo);
procedure SockClientSetGlobal(Const I: ShortString;
Const P: Word);
Routine is public for use by client mode developers who wish to push socket handles from one application to another.
procedure SetTimeoutAndBuffer(Const SockHandle: Integer);
This routine is called internally every time a socket is created, it sets the largest buffer size possible for reads and writes at the socket layer, and adjusts the timeout for calls to fast as possible for DXSock code can handle the situation better.
function DroppedConnection: Boolean;
This routine is a wrapper around Connected, some people like to have their code like if DroppedConnection then... instead of if connected then.
function WaitForData(Const timeout: Longint): Boolean;
This is a simple routine for those who do not like to use my example of while connected and is readable checking. You simply call WaitForData and tell DXSock how long to wait before timeout occurs if no data is received.
procedure RestartCharactersPerSecondTimer;
function CharactersPerSecondWritten: Integer;
function CharactersPerSecondReceived: Integer;
function CharactersPerSecondWrittenBytes: Cardinal;
function CharactersPerSecondReceivedBytes: Cardinal;
function GetSessionCommand(Const Commands:Array of AnsiString;
Var Params:AnsiString):Integer;
TBPDXSock Properties
property BindTo: ShortString;
property Connected: Boolean; Read-Only
property CharactersToRead: Integer; Read-Only
property ReceiveLength: Integer; Read-Only
property ValidSocket: Boolean; Read-Only
property LastReadTimeout: Boolean; Read-Only
property LastCommandStatus: Integer;
property OutputBufferSize: TBPDXBlockSizeFlags;
property TooManyCharacters: Integer;
property IsUDPMode: Boolean;
property IsKeepAliveMode: Boolean;
property PeerIPAddress: ShortString;
property PeerPort: Integer;
property PeerPortAsString: ShortString;
property LocalIPAddress: ShortString;
property LocalPort: Integer;
property Readable: Boolean;
property UsingOpenSSL:Boolean;
Public Methods (Outside of an Object)
function GetAddressCountByHost(Const Host: AnsiString): Integer;
function GetIPAddressByHost(Const Host: AnsiString;
Const Which: Integer): ShortString;
function CreateSocket(const sin_family, socket_type, protocol: integer;
var ErrorCode: Integer): TSocket;
Related Keyword:
routine,
function,
socket,
integer,
const,
provides,
layer,
data,
property,
tbpdxsock,
read,
boolean,
timeout