[twsocket] Two things in ICS (probably bug/potential bug)

2011-02-01 Thread Anton S.
I just downloaded recent version from SVN and found a strange define in 
OverbyteIcsDefs.inc
{$IFDEF CLR}
  {$DEFINE BOMB}
{$ELSE}
  {$IFNDEF COMPILER7_UP}
{$DEFINE BOMB}
  {$ENDIF}
{$ENDIF}
It seems that it shouldn't really be CLR but old versions of BCB or something 
else.

And the second thing, I faced with Range check errors inside ICS code. After 
some investigations I've found the root of evil: _PostMessage in 
TCustomWSocket.Send takes wParam as Integer while FHSocket it is called with 
has unsigned type Cardinal. Casting FHSocket to Integer resolved the issue. 
There are several other places where socket handle is posted so I think they 
should be fixed too. And consider using WPARAM/LPARAM types for casting instead 
of general integer ones for higher compatibility.
Moreover, after I've learned some thing regarding x64 I accepted the habit of 
sending/posting pointers/handles ONLY in LParam which is what it intended for. 
So it'd be nice to see it in ICS.

-- 
Anton
--
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


Re: [twsocket] Two things in ICS (probably bug/potential bug)

2011-02-01 Thread Arno Garrels
Anton S. wrote:
> I just downloaded recent version from SVN and found a strange define
> in OverbyteIcsDefs.inc {$IFDEF CLR}
>  {$DEFINE BOMB}
> {$ELSE}
>  {$IFNDEF COMPILER7_UP}
>{$DEFINE BOMB}
>  {$ENDIF}
> {$ENDIF}
> It seems that it shouldn't really be CLR but old versions of BCB or
> something else. 

It's not for .NET however for Delphi 7+ and BCB 2006+, what is the
problem?

> 
> And the second thing, I faced with Range check errors inside ICS
> code. After some investigations I've found the root of evil:
> _PostMessage in TCustomWSocket.Send takes wParam as Integer while
> FHSocket it is called with has unsigned type Cardinal. Casting
> FHSocket to Integer resolved the issue. 

FHSocket actually is of type TSocket = u_int = Integer defined in 
Winsock.pas, WPARAM and LPARAM are of type Integer defined in 
Windows.pas, there is no cast required. Do you use Delphi?

> And consider using WPARAM/LPARAM types for casting instead of
> general integer ones for higher compatibility.

Agreed.

> Moreover, after I've
> learned some thing regarding x64 I accepted the habit of
> sending/posting pointers/handles ONLY in LParam which is what it
> intended for. So it'd be nice to see it in ICS. 

Currently both WPARAM and LPARAM are 32-bit and will be 64-bit 
in x64, no problem IMO. 

-- 
Arno Garrels
--
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


Re: [twsocket] Install ICS SSL Delphi 2007 Problem NO SSL

2011-02-01 Thread Marc Hale
It is version 7 I even re-download it from the site to make sure I had the
latest version. If I install the same code on one of my machines its fine.
But on my new machine it won't install the SSL.

I even copied all the registry settings from my old machine for Delphi 2007

I even copied the same info to my Delphi 2010 install and it installs the
SSL fine.

Is there some setting in Delphi 2007 I'm missing

-Original Message-
From: twsocket-boun...@elists.org [mailto:twsocket-boun...@elists.org] On
Behalf Of Francois PIETTE
Sent: Tuesday, February 01, 2011 2:11 AM
To: ICS support mailing
Subject: Re: [twsocket] Install ICS SSL Delphi 2007 Problem NO SSL

You installed ICS-V5  instead of V7 ?

--
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: "Marc Hale" 
To: 
Sent: Tuesday, February 01, 2011 2:28 AM
Subject: [twsocket] Install ICS SSL Delphi 2007 Problem NO SSL


> Just got a new PC and installed Delphi 2007 trying to install ICS SSL 
> which i already have installed on my 2 other machines working fine.
>
> not matter what i do when i build and install the 2007 group it will not 
> install SSL. i have check the package and USE SSL is defined.
>
> i compiled it on a different computer and all fine. copied the code back 
> to my new computer and compiled it and ssl will not install
>
> Please help.

--
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


Re: [twsocket] Two things in ICS (probably bug/potential bug)

2011-02-01 Thread Anton S.
>It's not for .NET however for Delphi 7+ and BCB 2006+, what is the
>problem?
Do you mean that ICS currently couldn't be compiled under .NET?

>FHSocket actually is of type TSocket = u_int = Integer defined in 
>Winsock.pas, WPARAM and LPARAM are of type Integer defined in 
>Windows.pas, there is no cast required. Do you use Delphi?
Aah, I remembered. I changed Winsock.pas so that TSocket is Cardinal which 
really is what it should be (U_int is unsigned undoubtedly, and declaring 
socket as signed is a bug leading to another range check errors in some cases). 
I hope this bug would sometimes be fixed so it's better to cast it explicitly.

>Currently both WPARAM and LPARAM are 32-bit and will be 64-bit 
>in x64, no problem IMO. 
Ok, I didn't know what WPARAM is on x64, tried searching in header files but 
haven't found the declaration. So if they are identical, no problem here.

-- 
Anton
--
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


[twsocket] TWSocketServer: client not removed from server list on disconnect

2011-02-01 Thread Anton S.
I faced strange issue when connected clients seem not to be removed from 
server's list on disconnect.
I wrote simple demo project to test this, it'll be later. In short words, 
client objects seem to never be deleted from FClientList. I've set breakpoint 
on the line "FClientList.Remove(AComponent)" in 
TCustomWSocketServer.Notification - it's never reached. So client is destroyed, 
but server still thinks he has it, and when destroying the server or calling 
DisconnectAll the exception "Invalid pointer operation" is raised.

Here's the demo:

== start ==

unit Servers;

interface

uses
  Windows, Messages, SysUtils, Classes, StrUtils, DateUtils,
  OverbyteIcsWSocket, OverbyteIcsWinsock, OverbyteIcsLogger,
  OverbyteIcsWSocketS, OverbyteIcsWndControl;

procedure ServersInit;
procedure ServersFree;

implementation

type
  TSrvClient = class(TWSocketClient)
  protected
FList: TList;
  public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
  end;

  TServer = class(TCustomWSocketServer)
  protected
procedure TriggerClientConnect(Client: TWSocketClient; Error: Word); 
override;
procedure TriggerClientDisconnect(Client: TWSocketClient; Error: Word); 
override;
  public
constructor Create(AOwner: TComponent); override;
  end;

var Server: TServer;

procedure ServersInit;
begin
  Server := TServer.Create(nil);{}
  Server.ClientClass := TSrvClient;
  Server.Listen;
end;

procedure ServersFree;
begin
  FreeAndNil(Server);
end;

constructor TSrvClient.Create(AOwner: TComponent);
begin
  inherited;
  CreateCounter;
  ComponentOptions := [wsoNoReceiveLoop];
  FList := TList.Create;
end;

destructor TSrvClient.Destroy;
begin
  FreeAndNil(FList); // *** set breakpoint here to ensure client is destroyed 
***
end;

constructor TServer.Create(AOwner: TComponent);
begin
  inherited;
  Proto   := 'tcp';
  Addr:= '0.0.0.0';  // Use any interface
  Port:= '1';
  ClientClass := TSrvClient; // Use our component
  Banner  := '';
  BannerTooBusy   := '';
end;

procedure TServer.TriggerClientConnect(Client: TWSocketClient; Error: Word);
begin
  inherited;
  Client.SendLine('Connect OK, closing...');
  Client.CloseDelayed;
end;

procedure TServer.TriggerClientDisconnect(Client: TWSocketClient; Error: Word);
begin
  inherited;
end;

end.

== end ==

How to test.

Save this as unit Servers, start new VCL app, use the unit, drop 2 buttons and 
create handlers:
procedure TForm1.Button1Click(Sender: TObject);
begin
  ServersInit;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  ServersFree;
end;

Run the app, push the 1st button. Launch cmd.exe and type "telnet localhost 
1". You'll receive a message and connection will be closed. But breakpoint 
on the line "FClientList.Remove(AComponent)" in 
TCustomWSocketServer.Notification isn't reached. Now push the 2nd button. 
Exception.

I believe in TCustomWSocketServer.WMClientClosed RemoveComponent should be 
called before Client.Free. I tried it and everything's OK.

-- 
Anton
--
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


Re: [twsocket] TWSocketServer: client not removed from server list on disconnect

2011-02-01 Thread Tobias Rapp
Hello Anton!

> destructor TSrvClient.Destroy;
> begin
>   FreeAndNil(FList); // *** set breakpoint here to ensure client is destroyed 
> ***
> end;

This should be:

destructor TSrvClient.Destroy;
begin
  FreeAndNil(FList); 
  inherited;  // <-- added call to ancestor
end;

Regards,
Tobias

--
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


Re: [twsocket] TWSocketServer: client not removed from server list on disconnect

2011-02-01 Thread Anton S.
Tobias, oh, thanks a lot! Today is the day when I use to forget to call 
ancestors' methods :)

-- 
Anton
--
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


Re: [twsocket] TWSocketServer: client not removed from server list on disconnect

2011-02-01 Thread Fastream Technologies
Probably because it is automatic in C++(?)

Regards,

SZ
On Tue, Feb 1, 2011 at 5:53 PM, Anton S.  wrote:

> Tobias, oh, thanks a lot! Today is the day when I use to forget to call
> ancestors' methods :)
>
> --
> Anton
>  --
> 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


Re: [twsocket] Two things in ICS (probably bug/potential bug)

2011-02-01 Thread Arno Garrels
Anton S. wrote:
>> It's not for .NET however for Delphi 7+ and BCB 2006+, what is the
>> problem?
> Do you mean that ICS currently couldn't be compiled under .NET?

The .NET code in V7 is unfinished work, it never compiled.

> 
>> FHSocket actually is of type TSocket = u_int = Integer defined in
>> Winsock.pas, WPARAM and LPARAM are of type Integer defined in
>> Windows.pas, there is no cast required. Do you use Delphi?
> Aah, I remembered. I changed Winsock.pas so that TSocket is Cardinal
> which really is what it should be (U_int is unsigned undoubtedly, and
> declaring socket as signed is a bug leading to another range check
> errors in some cases). I hope this bug would sometimes be fixed so
> it's better to cast it explicitly.

I doubt that Winsock.pas will see such a change, it's historical.

-- 
Arno Garrels



--
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


Re: [twsocket] Install ICS SSL Delphi 2007 Problem NO SSL

2011-02-01 Thread Francois PIETTE

I probably have another stupid question : How do you know you have not SSL
installed ?
Make sur you have only one OverbyteIcsD2007Run.bpl and one
OverbyteIcsD2007Design.bpl  file anywhere on your harddisk. You may also
delete every file OverbyteIcs*.dcu anywhere on you harddisk.

--
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: "Marc Hale" 

To: "'ICS support mailing'" 
Sent: Tuesday, February 01, 2011 12:33 PM
Subject: Re: [twsocket] Install ICS SSL Delphi 2007 Problem NO SSL



It is version 7 I even re-download it from the site to make sure I had the
latest version. If I install the same code on one of my machines its fine.
But on my new machine it won't install the SSL.

I even copied all the registry settings from my old machine for Delphi
2007

I even copied the same info to my Delphi 2010 install and it installs the
SSL fine.

Is there some setting in Delphi 2007 I'm missing

-Original Message-
From: twsocket-boun...@elists.org [mailto:twsocket-boun...@elists.org] On
Behalf Of Francois PIETTE
Sent: Tuesday, February 01, 2011 2:11 AM
To: ICS support mailing
Subject: Re: [twsocket] Install ICS SSL Delphi 2007 Problem NO SSL

You installed ICS-V5  instead of V7 ?

--
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: "Marc Hale" 
To: 
Sent: Tuesday, February 01, 2011 2:28 AM
Subject: [twsocket] Install ICS SSL Delphi 2007 Problem NO SSL



Just got a new PC and installed Delphi 2007 trying to install ICS SSL
which i already have installed on my 2 other machines working fine.

not matter what i do when i build and install the 2007 group it will not
install SSL. i have check the package and USE SSL is defined.

i compiled it on a different computer and all fine. copied the code back
to my new computer and compiled it and ssl will not install

Please help.


--
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


Re: [twsocket] Two things in ICS (probably bug/potential bug)

2011-02-01 Thread Francois PIETTE

It's not for .NET however for Delphi 7+ and BCB 2006+, what is the
problem?

Do you mean that ICS currently couldn't be compiled under .NET?


The .NET code in V7 is unfinished work, it never compiled.


Unfinished work, sure. But it worked at some point. And from trhat point 
changes have been made with no effort to keep it running because no one 
seems interested anymore in a .NET version.


--
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

--
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


Re: [twsocket] Install ICS SSL Delphi 2007 Problem NO SSL

2011-02-01 Thread Marc Hale
I removed the USE_SSL to make it do the SSL not matter what then I get
ERRORS on all the TSSL* files undelcarded ident

-Original Message-
From: twsocket-boun...@elists.org [mailto:twsocket-boun...@elists.org] On
Behalf Of Francois PIETTE
Sent: Tuesday, February 01, 2011 3:08 PM
To: ICS support mailing
Subject: Re: [twsocket] Install ICS SSL Delphi 2007 Problem NO SSL

I probably have another stupid question : How do you know you have not SSL
installed ?
Make sur you have only one OverbyteIcsD2007Run.bpl and one
OverbyteIcsD2007Design.bpl  file anywhere on your harddisk. You may also
delete every file OverbyteIcs*.dcu anywhere on you harddisk.

--
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: "Marc Hale" 
To: "'ICS support mailing'" 
Sent: Tuesday, February 01, 2011 12:33 PM
Subject: Re: [twsocket] Install ICS SSL Delphi 2007 Problem NO SSL


> It is version 7 I even re-download it from the site to make sure I had the
> latest version. If I install the same code on one of my machines its fine.
> But on my new machine it won't install the SSL.
>
> I even copied all the registry settings from my old machine for Delphi
> 2007
>
> I even copied the same info to my Delphi 2010 install and it installs the
> SSL fine.
>
> Is there some setting in Delphi 2007 I'm missing
>
> -Original Message-
> From: twsocket-boun...@elists.org [mailto:twsocket-boun...@elists.org] On
> Behalf Of Francois PIETTE
> Sent: Tuesday, February 01, 2011 2:11 AM
> To: ICS support mailing
> Subject: Re: [twsocket] Install ICS SSL Delphi 2007 Problem NO SSL
>
> You installed ICS-V5  instead of V7 ?
>
> --
> 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: "Marc Hale" 
> To: 
> Sent: Tuesday, February 01, 2011 2:28 AM
> Subject: [twsocket] Install ICS SSL Delphi 2007 Problem NO SSL
>
>
>> Just got a new PC and installed Delphi 2007 trying to install ICS SSL
>> which i already have installed on my 2 other machines working fine.
>>
>> not matter what i do when i build and install the 2007 group it will not
>> install SSL. i have check the package and USE SSL is defined.
>>
>> i compiled it on a different computer and all fine. copied the code back
>> to my new computer and compiled it and ssl will not install
>>
>> Please help.
>
> --
> 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

--
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


[twsocket] Built-in timeout questions

2011-02-01 Thread Anton S.
Hello all,
recently I've started migrating from my own timeout-featured TWSocket 
descendant towards the ICS built-in timeout. First of all, thanks to Arno for 
implementing this feature!
Usage is quite simple and most of the questions could be answered by reading 
the code but some things are still lurking in the dark.
Here are my questions:

1) In my descendant class I implement true asynchronous Connect with 
asynchronous DNS lookup before connecting. Of course, I wish to use built-in 
timeout mechanism for tracking timeouts. But descendant classes haven't access 
to necessary fields, namely FTimeoutConnectStartTick. And without it I have no 
means of controlling the timeout. There are two ways as I see it: make 
FTimeoutConnectStartTick protected or even public - like Counter field is - or 
add a parameter to TimeoutStartSampling with type TTimeoutReason. Inside this 
method when parameter is torConnect, FTimeoutConnectStartTick would be 
assigned. Or, async DNS lookup before connect could be implemented in TWSocket 
what is the best decision IMHO :)

2) I have listening socket and wish to have its clients disconnected by 
inactivity timeout. Alas, the sockets created by Accept are never ininialized 
with timeout code. Of course, I may execute their TimeoutStartSampling manually 
but then another issue is revealing: TimeoutStartSampling creates Counter but 
doesn't init it, leaving its fields empty. So in case when client is connecting 
but sends or receives nothing, it is timeouted immediately! So I guess there 
should be FCounter.LastSendTick := _GetTickCount after CreateCounter. Regarding 
accepted sockets I guess some additions should be made too (for example, 
copying timeout fields from Server to newly created socket) but it's not so 
critical.

3) I have a TTimer in my thread which owns sockets. May I use TIcsThreadTimer 
instead and would it be more effective or no difference?

-- 
Anton
--
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


Re: [twsocket] Two things in ICS (probably bug/potential bug)

2011-02-01 Thread Anton S.
Arno wrote:
>The .NET code in V7 is unfinished work, it never compiled.

Francois wrote:
>Unfinished work, sure. But it worked at some point. And from trhat point 
>changes have been made with no effort to keep it running because no one 
>seems interested anymore in a .NET version.

Ah, now things are clear. Very pity - lots of efforts in vain! Delphi.Net seem 
to be unuseful thing at all though idea is great.

-- 
Anton
--
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