How do you exactly call this?
"call ReceiveFrom to get data."

Extracted from sample program OverbyteIcsUdpLstn1.pas:

procedure TMainForm.WSocketDataAvailable(Sender: TObject; Error: Word);
var
   Buffer : array [0..1023] of AnsiChar;
   Len    : Integer;
   Src    : TSockAddrIn;
   SrcLen : Integer;
begin
   SrcLen := SizeOf(Src);
   Len    := WSocket.ReceiveFrom(@Buffer, SizeOf(Buffer), Src, SrcLen);
   if Len >= 0 then begin
       if (FSenderAddr.S_addr = INADDR_ANY) or
          (FSenderAddr.S_addr = Src.Sin_addr.S_addr) then begin
           Buffer[Len] := #0;
DataAvailableLabel.Caption := IntToStr(atoi(DataAvailableLabel.caption) + 1) + ' ' + String(StrPas(inet_ntoa(Src.sin_addr))) + ':' + IntToStr(ntohs(Src.sin_port)) +
                                         '--> ' + String(StrPas(Buffer));
       end;
   end;
end;

--
francois.pie...@overbyte.be
http://www.overbyte.be


----- Original Message ----- From: "Signed Source® Project" <dan...@signedsource.com>
To: "ICS support mailing" <twsocket@elists.org>
Sent: Thursday, December 02, 2010 2:27 PM
Subject: Re: [twsocket] TWSocket UDP capturing


Hi Francois,
Thanks for the response,
How do you exactly call this?
"call ReceiveFrom to get data."

Thanks

-daniel


On 2.12.2010 14:51, Francois PIETTE wrote:
Hi !

  wsocketMain.Addr := '172.16.16.133';

delete this one unless you want to listen only to this interface. Use 0.0.0.0 (the default) to listen on all interfaces.

procedure TfrmMain.wsocketMainSessionAvailable(Sender: TObject; ErrCode:

No session with UDP, it is a connectionless protocol.
Use OnDataAvailable event and call ReceiveFrom to get data.

--
francois.pie...@overbyte.be
The author of the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be


----- Original Message ----- From: "Signed Source® Project" <dan...@signedsource.com>
To: "ICS Components" <twsocket@elists.org>
Sent: Thursday, December 02, 2010 1:08 PM
Subject: [twsocket] TWSocket UDP capturing


Hi guys,
I am trying to capture UDP packages from a device placed in my network with TWSocket.
I am unfortunately lost because I don't know how to do it.
I will be very pleased if there are any samples, if not I can put this one on the site after I made it working because it will basically look like a demo.

Here is my code,
Could you please check and give me some ideas about what is missing and what I need to do?
.................................................................................................................................................................
[procedure TfrmMain.btnClearClick(Sender: TObject);
begin
  memoPackets.Clear;
end;

procedure TfrmMain.btnCloseClick(Sender: TObject);
begin
  Close;
  Forms.Application.Terminate;
end;
 {Here I am trying to set parameters and put the socket to listen}
procedure TfrmMain.btnStartClick(Sender: TObject);
begin
  wsocketMain.Proto := 'udp';
  wsocketMain.Port := '49494';
  wsocketMain.Addr := '172.16.16.133';
  wsocketMain.Listen;
end;

{Here I am trying to close the socket}
procedure TfrmMain.btnStopClick(Sender: TObject);
begin
  wsocketMain.Close;
end;

{Here I am trying to add captured data to the memo}
procedure TfrmMain.wsocketMainSessionAvailable(Sender: TObject; ErrCode: Word);
begin
  memoPackets.Lines.Add(wsocketMain.ReceiveStr) //??
end;

end.]

--
-daniel

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to