📄 dxsock.pas
字号:
// means of knowing when it has received the complete file. This
// can be overcome by prefixing some form of header before the
// file is sent, or suffixing the file with a unique terminator.
//
//
//
// Returns
// <COLOR BORLAND GREEN>The result is true if successfully, or
// false if there was an error.</COLOR>
// =======================================================================
function SendFrom (var Handle:file) :boolean;overload; dynamic;
{$ENDIF}
// ===========================================================================
// This routine provides a mechanism that automatically prefixes
// the stream of with a header of the size of the stream.
//
// Note
// It starts sending from the current positions in the stream
// and continues until it has sent the remainder of the stream.
//
// Returns
// <COLOR BORLAND GREEN>The result is true if successfully, or
// false if there was an error.</COLOR>
// ===========================================================================
function SendFromStreamWithSize (Stream:TStream) :Boolean; dynamic;
// =================================================================
// This routine is provided to make your transition from using
// the Borland socket implementation to DXSock much easier. It
// functions exactly like the read() routine.
//
// Returns
// <COLOR BORLAND GREEN>The result is the number of bytes
// received. Test the LastReadTimeout and LastCommandStatus
// properties discussed in the next section of this chapter.</COLOR>
// =================================================================
function ReceiveBuf (var Buf;Count:Integer) :Integer; virtual;
{$IFDEF VER100}
function BlockRead (buf:Pointer;len:Integer) :Integer; virtual;
function Read:Char; dynamic;
{$ELSE}
// ========================================================================
// This routine provides a mechanism for receiving data from the
// socket layer for the specified length as a pointer.
//
// Note
// This method is internally called by all of the routines used
// to receive data, thus the timeouts parameter had to be
// ignored internally for this routine.
//
//
//
// Returns
// <COLOR BORLAND GREEN>The result is the number of bytes
// successfully received without error. Test the LastReadTimeout
// and LastCommandStatus properties discussed in the next
// section of this chapter.</COLOR>
//
// ========================================================================
function Read (buf:Pointer;len:Integer) :Integer;overload; virtual;
// ============================================================
// This routine provides a mechanism for receiving a single
// character from the socket layer within the specified
// milliseconds.
//
//
//
// Note
// Anytime you interact with a socket buffer
// character-by-character, you will see a severe performance
// drop. In 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 and thus producing a severe
// performance drop.
//
//
//
// Returns
// <COLOR BORLAND GREEN>The result is the actual character
// received if no error occurred otherwise it will return #0.
// Test the LastReadTimeout and LastCommandStatus properties
// discussed in the next section of this chapter.</COLOR>
// ============================================================
function Read:Char;overload; dynamic;
{$ENDIF}
// ==============================================================
// This routine provides you with a mechanism for receiving
// 32-bit numbers as a 4-byte piece of data. Internally it swaps
// the high and low bytes as to be compatible with over
// \operating systems. This is used by the routines which
// present this number as a form of length header - in DXSock
// and DXInternet: ReadWithSize and SaveToStreamWithSize,
// WriteWithSize and SendFromStreamWithSize.
//
// Returns
// <COLOR BORLAND GREEN>If no error occurred the actual number
// received is returned otherwise it would return -1. Test the
// LastReadTimeout and LastCommandStatus properties discussed in
// the next section of this chapter.</COLOR>
// ==============================================================
function ReadInteger:integer; dynamic;
// =============================================================
// 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
// ignores the timeout parameter.
//
// Returns
// <COLOR BORLAND GREEN>The result is a string of up to
// MaxLength characters, or "" if an error occurred. Test the
// LastReadTimeout and LastCommandStatus properties discussed in
// the next section of this chapter.</COLOR>
// =============================================================
function ReadStr (MaxLength:Integer) :string; dynamic;
// ==============================================================
// 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.
//
// Returns
// <COLOR BORLAND GREEN>The result is a string of up to
// MaxLength characters, or "" if an error or timeout occurred.
// Test the LastReadTimeout and LastCommandStatus properties
// discussed in the next section of this chapter.</COLOR>
// ==============================================================
function ReadString (MaxLength:Integer;Timeout:Longword) :string; virtual;
// =================================================================
// 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.
//
// Returns
// <COLOR BORLAND GREEN>The result is a string of prior to the
// first occurrence of the delimiter character(s), or "" if an
// error or timeout occurred. Since the client could potentially
// send a blank line, you should not assume an error has
// \occurred. Test the LastReadTimeout and LastCommandStatus
// properties discussed in the next section of this chapter.</COLOR>
// =================================================================
function ReadLn (Timeout:Longword) :string; virtual;
// =================================================================
// 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.
//
// Returns
// <COLOR BORLAND GREEN>The result is a string of prior to the
// first occurrence of the delimiter characters, or "" if an
// error or timeout occurred. Since the client could potentially
// send a blank line, you should not assume an error has
// \occurred. Test the LastReadTimeout and LastCommandStatus
// properties discussed in the next section of this chapter.</COLOR>
// =================================================================
function ReadCRLF (Timeout:Longword) :string; dynamic;
// ==================================================================================
// 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.
//
//
//
// Returns
// <COLOR BORLAND GREEN>The result is a string of prior to the
// first occurrence of the delimiter character(s), or "" if an
// error or timeout occurred. Since the client could potentially
// send a blank line, you should not assume an error has
// \occurred. Test the LastReadTimeout and LastCommandStatus
// properties discussed in the next section of this chapter.</COLOR>
//
// ==================================================================================
function ReadToAnyDelimiter (Timeout:Longword;Delimiter:string) :string; dynamic;
// =================================================================
// 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.
//
// Returns
// <COLOR BORLAND GREEN>The result is a string of prior to the
// first occurrence of the Null delimiter character, or "" if an
// error or timeout occurred. Since the client could potentially
// send a blank line, you should not assume an error has
// \occurred. Test the LastReadTimeout and LastCommandStatus
// properties discussed in the next section of this chapter.</COLOR>
// =================================================================
function ReadNull (Timeout:Longword) :string; dynamic;
// ========================================================================
// 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.
//
// Returns
// <COLOR BORLAND GREEN>The result is a string of prior to the
// first occurrence of the space-bar delimiter character, or ""
// if an error or timeout occurred. Since the client could
// potentially send a blank line, you should not assume an error
// has occurred. Test the LastReadTimeout and LastCommandStatus
// properties discussed in the next section of this chapter.</COLOR>
// ========================================================================
function ReadSpace (Timeout:Longword) :string; dynamic;
// ==============================================================
// 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.
//
// Returns
// <COLOR BORLAND GREEN>The result is a string. Test the
// LastReadTimeout and LastCommandStatus properties discussed in
// the next section of this chapter.</COLOR>
// ==============================================================
function ReadWithSize:string; dynamic;
{$IFDEF VER100}
function SaveToStream (Stream:TStream;Timeout:Longword) :Boolean; virtual;
function SaveToWindowsFile (var Handle:Integer;Timeout:Longword) :boolean; dynamic;
function SaveToBorlandFile (var Handle:file;Timeout:Longword) :boolean; dynamic;
{$ELSE}
// =================================================================
// This routine provides a mechanism to simplify receiving a
// stream of data from the socket layer.
//
// Note
// It starts appending at the current position in the stream and
// continues until no more data can be received within a
// specified timeout. A common mistake is the assumption that
// the timeout counter resets when any data is received. Instead
// \of the timeout parameter is the maximum time this routine
// should execute.
//
//
//
// Returns
// <COLOR BORLAND GREEN>The result is true if any data was
// received. Test the LastReadTimeout and LastCommandStatus
// properties discussed in the next section of this chapter.</COLOR>
//
// =================================================================
function SaveTo (Stream:TStream;Timeout:Longword) :Boolean;overload; virtual;
// =================================================================
// This routine provides a mechanism to simplify receiving data
// from the socket layer and storing it in the specified
// \operating system file handle.
//
// Note
// It starts appending at the current position in the file and
// continues until no more data can be received within a
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -