Difference between revisions of "TWSocket.Receive"

From Overbyte
Jump to navigation Jump to search
(first entry)
 
(Example reformatted)
Line 1: Line 1:
[[Main_Page | Main page]] -> [[ICS_Components_Reference | ICS component reference]] -> [[TWSocket]] -> [[TWSocket.Receive | eceive]]
+
[[Main_Page | Main page]] -> [[ICS_Components_Reference | ICS component reference]] -> [[TWSocket]] -> [[TWSocket.Receive | Receive]]
  
 
== Definition ==
 
== Definition ==
Line 11: Line 11:
 
== Example ==
 
== Example ==
  
procedure WSocket1OnDataAvailable(Sender: TObject; ErrCode: Word);
+
  procedure WSocket1OnDataAvailable(Sender: TObject; ErrCode: Word);
var buf:array[1..64] of byte;
+
  var buf:array[1..64] of byte;
    len:nteger;
+
  len:nteger;
begin
+
  begin
  if ErrCode <> 0 then exit;
+
    if ErrCode <> 0 then exit;
 +
    len:=Receive(@buf, sizeof(buf));
  
  len:=Receive(@buf, sizeof(buf));
+
    // here your procesing of the data will take place
end;
+
  end;
  
 
== Best practices ==
 
== Best practices ==
  
 
== How to ==
 
== How to ==

Revision as of 11:02, 13 September 2006

Main page -> ICS component reference -> TWSocket -> Receive

Definition

method Receive(Buffer:Pointer; BufferSize:Integer: integer;

Description

Receive is used in the OnDataAvailable-Event to actually fetch the received data. The parameters needed are a buffer where the data will be placed and the size of that buffer. The return value of Receive specifies how many bytes where actually read and put in the buffer. If the buffer is too small, OnDataAvailable will occur again until all data is received.

Example

  procedure WSocket1OnDataAvailable(Sender: TObject; ErrCode: Word);
  var buf:array[1..64] of byte;
  len:nteger;
  begin
    if ErrCode <> 0 then exit;
    len:=Receive(@buf, sizeof(buf));
    // here your procesing of the data will take place
  end;

Best practices

How to