Hi Angus,
I had try it out but failed, client did not rcv any data. Any idea?
BTW, can this method used to broadcast?
procedure TForm1.WSocket1DataAvailable(Sender: TObject; ErrCode: Word);
var
saddr: TSockAddrIn;
saddrlen : integer;
dwPortX,dwIPX : DWORD;
srcv : String;
begin
srcv := WSocket1.ReceiveStr( );
Memo1.Lines.Add( 'Svr rcv ' + IntToHex(integer(GetTickCount( )),8) +
' --- ' + srcv );
saddrlen := sizeof(TSockAddrIn);
WSocket2.GetSockName( saddr,saddrlen );
dwPortX := WSocket_ntohs( saddr.sin_port ); // Get the port assigned
automatic by winsock
// New added portion - start, but failed --
// if ( wsClosed = WSocket6.State ) then
//WSocket6.Connect( );
// WSocket6.sin.sin_addr.s_addr :=
WSocketResolveHost(WSocket6.Addr).s_addr;
// WSocket6.sin.sin_port:= dwPortX;
// New added portion - end, but failed --
// Old method - working
if ( wsConnected = WSocket6.State ) then
if ( (WSocket6.Port '0') and (StrToInt(WSocket6.Port) dwPortX) )
then
begin
WSocket6.Close( );
WSocket6.Free( );
WSocket6 := TWSocket.Create( Self );
WSocket6.Addr := '255.255.255.255';
WSocket6.Port := '3313';
WSocket6.Proto := 'udp';
WSocket6.LocalAddr := '0.0.0.0';
WSocket6.LocalPort := '0';
WSocket6.OnDataSent := WSocket4DataSent;
end;
while ( wsConnected WSocket6.State ) do
begin
Application.ProcessMessages( );
if ( wsClosed = WSocket6.State ) then
begin
WSocket6.Addr := '255.255.255.255';
WSocket6.LocalAddr := '0.0.0.0';
WSocket6.Port := IntToStr( dwPortX );
WSocket6.LocalPort := '0';
WSocket6.Connect( );
Application.ProcessMessages( );
end;
end;
if ( wsConnected = WSocket6.State ) then
// WSocket6.SendStr( 'xxx' );
WSocket6.Send( PChar('xxx'),3 );
end;
procedure TForm1.WSocket4DataSent(Sender: TObject; ErrCode: Word);
begin
Memo1.Lines.Add( (Sender AS TWSocket).Name + '/'+
IntToHex(StrToInt((Sender AS TWSocket).Port),4) +
'/'+ IntToHex(WSocket6.sin.sin_port,4) +
'/'+ IntToHex(WSocket6.sin.sin_addr.s_addr,8) +
'/'+ IntToHex(ErrCode,4) +
' Snd ' + IntToHex(integer(GetTickCount( )),8) );
end;
procedure TForm1.WSocket2DataAvailable(Sender: TObject; ErrCode: Word);
var
srcv : String;
begin
srcv := (Sender As TWSocket).ReceiveStr( );
Memo1.Lines.Add( ' Clent - ' + (Sender AS TWSocket).Name + 'Rcv ' +
IntToHex(integer(GetTickCount( )),8) + srcv );
end;
Regards,
KL Chin
-Original Message-
From: KL Chin [mailto:[EMAIL PROTECTED]
Sent: Friday, September 29, 2006 12:25 AM
To: ICS support mailing
Subject: RE: [twsocket] Sample Code Missing
Hi Angus,
Thx for your link. Will try by tomorrow.
Regards,
KL Chin
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Behalf Of Angus Robertson - Magenta Systems Ltd
Sent: Thursday, September 28, 2006 7:37 PM
To: twsocket@elists.org
Subject: Re: [twsocket] Sample Code Missing
The user made code for WSOCKETEXT.PAS was missing, where can I get
it?
It's included in the SNTP components zip on my page:
http://www.magsys.co.uk/delphi/magics.asp
Angus
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be