[twsocket] TIpFtp: suspicious code and other

2010-07-08 Thread Anton Sviridov
TCustomFtpCli.DoGetAsync contains lines to open file stream. But as far as I 
see exactly the same is implemented in CreateLocalFileStream method. Maybe it 
would be better to call it instead?

I would also like to know how can I attach to the moment of creating file to 
write. I want to set Hidden attr to files being downloaded and clear it on 
download finish, but I don't know where to place it. I could make 
OpenFileStream virtual but it's used in other places too - so it's hard to 
distinguish one case from another. Currently I see only one way: check OpenMode 
in OpenFileStream to determine whether the file is being opened for writing or 
not. Maybe you've got better ideas?

-- 
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] ICS v7, Connect fails if FTP server does not support FEAT

2010-06-10 Thread Anton Sviridov
> Sorry Anton, you'll need to change your application to use one of the new
> commands, but the change broke too many things. 

Angus, no problem: I use HighLevelAsync directly as it much more flexible and 
powerful than predefined methods

HighLevelAsync(ftpConnectAsync, [ftpFctOpen, ftpFctAuth, ftpFctUser, 
ftpFctPass, ftpFctAcct, ftpFctSyst, ftpFctFeat]);

I would also like to remind you (or Arno or Francois) of a planned change in 
error handling in FTPCli which we discussed a month ago.

-- 
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] (TFtpClient) Parsing list. Help, help.

2010-06-03 Thread Anton Sviridov
Hello!
Here's routine from TurboPower iPRO component pack which I improved a bit

{ Set properties from Unix style line of directory listing }
procedure TIpFtpFileInfo.UnixStyleParse(Info : TStringList);
var
  S, A : string;
  i, idx : Integer;
  wYear, wMonth, wDay, wHour, wMin, shit: Word;
  fs: TFormatSettings;
begin
  // Get defaults for file creation date/time
  DecodeDate(GetTimeFn, wYear, wMonth, wDay);
  DecodeTime(GetTimeFn, wHour, wMin, shit, shit);

  {File Type}
  S := Info[0];
  case UpCase(S[1]) of
'-' : FFileType := ftFile;
'D' : FFileType := ftDir;
//'L' : FFileType := ftLink;
'L' : FFileType := ftDir;
  else
FFileType := ftUnknown;
  end;

  {Owner Permissions}
  FPermissions.Owner := [];
  A := UpperCase(Copy(S, 2, 3));
  if CharPos('R', A) > 0 then  {!!.02}
FPermissions.Owner := FPermissions.Owner + [faRead];
  if CharPos('W', A) > 0 then  {!!.02}
FPermissions.Owner := FPermissions.Owner + [faWrite];
  if CharPos('X', A) > 0 then  {!!.02}
FPermissions.Owner := FPermissions.Owner + [faExecute];

  {Group Permissions}
  FPermissions.Group := [];
  A := UpperCase(Copy(S, 5, 3));
  if CharPos('R', A) > 0 then  {!!.02}
FPermissions.Group := FPermissions.Group + [faRead];
  if CharPos('W', A) > 0 then  {!!.02}
FPermissions.Group := FPermissions.Group + [faWrite];
  if CharPos('X', A) > 0 then  {!!.02}
FPermissions.Group := FPermissions.Group + [faExecute];

  {Other Permissions}
  FPermissions.Other := [];
  A := UpperCase(Copy(S, 8, 3));   {!!.02}
  if CharPos('R', A) > 0 then
FPermissions.Other := FPermissions.Other + [faRead];
  if CharPos('W', A) > 0 then  {!!.02}
FPermissions.Other := FPermissions.Other + [faWrite];
  if CharPos('X', A) > 0 then  {!!.02}
FPermissions.Other := FPermissions.Other + [faExecute];

  {Search index of date property - to avoid owner/group bad data}
  // Date field always starts with 3-letter month name
  GetLocaleFormatSettings(LANG_ENGLISH, fs);
  idx:=0;
  for i := 1 to Info.Count-1 do
if AnsiIndexStr(Info[i],fs.ShortMonthNames)<>-1 then
  begin idx:=i; Break; end;
  if idx=0 then Exit;

  // Get other fields relative to Date
  {Owner}
  if (idx-3 > 0) then
FOwner := Info[idx-3];

  {Group}
  if (idx-2 > 0) then
FGroup := Info[idx-2];

  {Size}
  if (idx-1 > 0) then
FSize := StrToIntDef(Info[idx-1], 0);

  {Time stamp}
  if (idx <= Info.Count + 2) then
  // parse timestamp. got it from Indy :)
  // format: "Feb 27 19:07" or "Sep 20 2001", that is,   |
  begin
FTimeStamp := Info[idx] + ' ' + Info[idx+1] + ' ' + Info[idx+2];
i:=AnsiIndexStr(Info[idx],fs.ShortMonthNames);
if i>=0 then wMonth := i+1;
wDay := StrToIntDef(Info[idx+1], wDay);
i:=Pos(':', Info[idx+2]);
if i = 0 then // Not time info, scan year
begin
  wYear := StrToIntDef(Info[idx+2], wYear);
  wHour := 0;
  wMin := 0;
end
else
begin // Time info, correct year, scan hour, min
  if MonthOf(GetTimeFn) < wMonth then
Dec(wYear);
  wHour:= StrToIntDef(Copy(Info[idx+2],1,i-1),0);
  wMin := StrToIntDef(Copy(Info[idx+2],i+1,Length(Info[idx+2])),0);
end;
FDateCreated := EncodeDate(wYear, wMonth, wDay) + EncodeTime(wHour, wMin, 
0, 0);
  end;

  {File name}
  FFileName := '';
  for i := idx+3 to Info.Count-1 do begin
if(Info[i] = '->')then
  break;
if (FFileName <> '') then
  FFileName := FFileName + ' ';
FFilename := FFileName + Info[i];
  end;

  {Symbolic Link}
  FLinkPath := '';
  if (FFileType = ftLink) then begin
for i := 0 to Pred(Info.Count) do
  if (Info[i] = '->') then
break;
if (i <= (Info.Count - 2)) then
  FLinkPath := Info[i + 1];
  end;
end;

Moreover, I created more powerful & robust ICS FTP client descendant with Unix, 
VMS, DOS listing parsing. Let me know if someone's interested.

-- 
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] FTPCli error handling

2010-05-24 Thread Anton Sviridov
>Well, we'll have to somehow determine local code errors then
I meant, "local errors' codes"

-- 
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] FTPCli error handling

2010-05-24 Thread Anton Sviridov
Hello Francois, hope you liked your trip :)

>Arno's suggestion looks good and wouldn't break any existing code.
Well, we'll have to somehow determine local code errors then. And not forget to 
clear the flag. But at least it will provide a way to deal with the problem.

>As far as I remember, you are the first to request the special handling for 
>local error codes.
Maybe the reason is that i'm developing a fully automated downloader requiring 
no or minimal user action. Of course interactive app could just throw an error 
message and let the user find a solution, but I need to distinguish occuring 
errors in order to perform appropriate actions.
Or - maybe somebody experienced in FTPCli could advise me how to handle the 
case I described in initial message (error with code 550 occured).

-- 
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] Winsock 1.1 and IPv6

2010-05-21 Thread Anton Sviridov
There's a socket lib written on C++ which seems to have async v6 resolving:

"2.1.1: Tcp socket Reconnect now works again. Improved ipv6 support. 
Asynchronous resolver now works with ipv6 too. Safer pointer handling using STL 
auto_ptr in some cases. Thread safety improvements, gethostby* functions has 
been replaced by getnameinfo/getaddrinfo."

I looked at the code, but they did something strange there, I can't realize 
their solution. Maybe you'll be able to?
Though I think the blocking issue shouldn't stop you because 
TCustomWSocket.Connect uses blocking WSocket_Synchronized_GetHostByName anyway.

-- 
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] Winsock 1.1 and IPv6

2010-05-19 Thread Anton Sviridov
> if support for winsock below v2.2 was actually required in 
> ICS v7?

As Wiki says,
Version 2.1 of Winsock was supplied in an add-on package for Windows 95. It was 
an integral component of Windows 98, Windows NT 4.0, and all subsequent Windows 
releases. (Microsoft did not supply implementations of Winsock 2 for Windows 
3.x or Windows NT 3.x.)

I don't think v7 could be launched on Win 3.x.

-- 
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] FTPCli error handling

2010-05-19 Thread Anton Sviridov
So, what will be your decision?
I wouldn't hurry you, but I have a buggy project based on old FTP components 
and wish to rebuild it with ICS.
Looking forward to your answer.

--
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] FTPCli error handling

2010-04-29 Thread Anton Sviridov
>Have you tried calling GetLastError or WSAGetLastError ?
I think it's unreliable because error can occur by exception not by Winsock or 
Windows error. Moreover, LastError-s could be overwritten by subsequent API 
calls by the moment OnRequestDone will be called.

-- 
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] FTPCli error handling

2010-04-29 Thread Anton Sviridov
Hello Arno,

>If a workaround is needed then IMO a field "FLastLocalError" of type
>LongWord or Integer could receive a meaningful error code and a method 
>GetLastLocalError could return and reset the value back to 0? 

Well, it's something. Though I'm still not sure what's the best way to deal 
with the issue.
Any flag or value must be somehow cleared after reporting (though 
TriggerRequestDone seems to be a nice place for it).
Maybe something like OnLocalError handler will work... unfortunately currently 
I have no idea of how to inject the workaround into the existing code properly.

-- 
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] FTPCli error handling

2010-04-29 Thread Anton Sviridov
Hello all,
it's me again and again with a question about FTPCli.
Current manner of reporting local errors is to set code 550 with an explaining 
message and call TriggerRequestDone. But I find it very confusing: for example, 
when trying to GET some file or directory listing we could receive "true FTP 
response" 550 if the requested file doesn't exist (so we should give up) as 
well as "ICS response" if connection couldn't be established (so we should 
retry) or there was error creating local file stream (so we should check HDD 
free space). And there's no way to distinguish these cases (except checking 
FLastResponse string, but I consider it rather unconvenient).
So I think something is needed to be done to differentiate local problems of 
remote ones. I'd prefer changing 550 code to some another value unused by FTP 
servers (maybe even over 600 to avoid intersections for sure) but the ICS 
policy is NOT BREAK existing code, so maybe some flag like FLocalErrorHappened: 
Boolean will solve the problem?
If you reject the idea please explain me how to deal with this response mess.

--
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] WSAECONNABORTED (10053) when connecting to server

2010-04-27 Thread Anton Sviridov
Hello all,
I faced strange issue in my app. I develop an application which opens ~15 
connections to several servers, ~3-5 connections per server. After establishing 
the connection it receives data flow.
But when I start it, some connections fail with WSAECONNABORTED (10053) - and 
the oddest thing is that they fail after receiving some data. Reconnect after 5 
sec pause works fine.

I asked our admin, but he says the PC which my app runs on has no restrictions 
on the router at all. Moreover, I have no problem on my own PC with XP (PC 
where I run app has W2003 server). So it is unlikely bug in my or ICS code.

I found description of MS bug here: http://support.microsoft.com/?kbid=931319 
and applied the patch provided, but it only turned the things worse so I 
uninstalled it.

Do you have any advice? Maybe someone have already faced with such issue?

-- 
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] Error "Socket operation on non-socket"

2010-04-22 Thread Anton Sviridov
>The safest way is to PostMessage a custom message from SessionClosed event 
>and reconnect from the corresponding event handler.

Well, that's exactly what I'm doing:
  if (not FInternalClose) and (FState in [csConnected, csRequesting, 
csReceivingData]) then
PostState(csReconnect);

So you recommend not to use immediate close? But according to the log I 
provided earlier, every routine is completed, even SocketSessionClosed is 
called.
I still suspect Linger options strongly.

-- 
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] Error "Socket operation on non-socket"

2010-04-22 Thread Anton Sviridov
Good morning to all,
I have done some investigations and noticed one interesting thing: the error 
appears only when the socket handle is equal to previous. Here's the log:

(SetState is my procedure to change client's state, and I also added to 
TWSocket code two log writes: "TCustomWSocket.Connected" + FHSocket, it is 
written after WSocket_Synchronized_socket call in TCustomWSocket.Connect, and 
"TCustomWSocket.Closed" + FHSocket, it is written after  FCloseInvoked := TRUE; 
TriggerSessionClosed(Error); in TCustomWSocket.InternalClose.

2010-04-21  18:33:49SetState: csSleeping -> csConnecting
2010-04-21  18:33:49TCustomWSocket.Connected 1112
2010-04-21  18:33:49SocketChangeState, wsClosed -> wsOpened
2010-04-21  18:33:49TWSocket will connect to 
2010-04-21  18:33:49SocketChangeState, wsOpened -> wsConnecting
2010-04-21  18:34:00Connection timeout
2010-04-21  18:34:00SetState: csConnecting -> csTimeout
2010-04-21  18:34:00SetState: csTimeout -> csReconnect
2010-04-21  18:34:00SetState: csReconnect -> csCloseNow
2010-04-21  18:34:0000D384D0 TCustomWSocket.Shutdown 1 1112
2010-04-21  18:34:00SocketChangeState, wsConnecting -> wsClosed
2010-04-21  18:34:00SocketSessionClosed
2010-04-21  18:34:00TCustomWSocket.Closed -1
2010-04-21  18:34:00Try to connect: (attempt 2 of 3)
2010-04-21  18:34:00SetState: csReconnect -> csConnecting
2010-04-21  18:34:00TCustomWSocket.Connected 1112
2010-04-21  18:34:00SocketChangeState, wsClosed -> wsOpened
2010-04-21  18:34:00TWSocket will connect to 
2010-04-21  18:34:00SocketChangeState, wsOpened -> wsConnecting
2010-04-21  18:34:00SocketChangeState, wsConnecting -> wsConnected
2010-04-21  18:34:00SocketSessionConnected, Socket operation on 
non-socket (#10038)
2010-04-21  18:34:0000D384D0 TCustomWSocket.Shutdown 1 1112
2010-04-21  18:34:00SocketChangeState, wsConnected -> wsClosed
2010-04-21  18:34:00SocketSessionClosed
2010-04-21  18:34:00TCustomWSocket.Closed -1

As you can see, socket is closed and handle cleared properly. But - the newly 
assigned handle is the same as previous. I suspect the error to happen because 
of half-open or a kind of "under-closed" socket: i.e. the one which isn't 
completely closed, but the OS considers it's handle to be free. Having read 
MSDN about closesocket() 
(http://msdn.microsoft.com/en-us/library/ms737582(VS.85).aspx), I guess that 
the reason is Linger options. But I have default values: FLingerOnOff := 
wsLingerOn; FLingerTimeout := 0, and MSDN says it is "Hard" type of close with 
no waiting.

So what's the right and proper way to reconnect a socket? Should I start 
reconnecting only from SocketSessionClosed?

-- 
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] Error "Socket operation on non-socket"

2010-04-16 Thread Anton Sviridov
Hello all,
sorry for doubling the messages - from web interface I somewhy can't see the 
text of my mails, though in the digest arrived text is present.

wilfried, dZ,
the strangest thing is that socket is created and connected directly before the 
bug. Here is what happens next:

2010-04-16  10:56:00SocketChangeState, wsClosed -> wsOpened
2010-04-16  10:56:00TWSocket will connect to 200.255.94.90:2101
2010-04-16  10:56:00SocketChangeState, wsOpened -> wsConnecting
2010-04-16  10:56:00SocketChangeState, wsConnecting -> wsConnected
2010-04-16  10:56:00SocketSessionConnected, Socket operation on 
non-socket (#10038)
2010-04-16  10:56:0000D41210 TCustomWSocket.Shutdown 1 1472
2010-04-16  10:56:00SocketChangeState, wsConnected -> wsClosed
2010-04-16  10:56:00SocketSessionClosed

I suppose if there was a sudden connection break, the Shutdown shouldn't have 
been called? Seems that problem is on the client side.
I searched through the log and noticed that line

00D41210 TCustomWSocket.Shutdown 1 1472

repeats several times (i.e. the same handle 1472 several times after closing!). 
Seems like not clearing socket handle. Strange...

-- 
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] Error "Socket operation on non-socket"

2010-04-16 Thread Anton Sviridov
*something wrong with my previous mail, retrying...*

>From time to time in my program I encounter strange error on connecting.
Here's a piece of socket log:

2010-04-16   10:55:50   SocketChangeState, wsClosed -> wsOpened
2010-04-16   10:55:50   TWSocket will connect to 200.255.94.90:2101
2010-04-16   10:55:50   SocketChangeState, wsOpened -> wsConnecting
2010-04-16   10:55:50   SocketChangeState, wsConnecting -> wsConnected
2010-04-16   10:55:50   SocketSessionConnected, Socket operation on non-socket 
(#10038)
2010-04-16   10:55:50   00D41210 TCustomWSocket.Shutdown 1 1472

Any ideas why it could happen?

--
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] Error "Socket operation on non-socket"

2010-04-16 Thread Anton Sviridov
*something wrong with my previous mail, retrying...*

>From time to time in my program I encounter strange error on connecting.
Here's a piece of socket log:

2010-04-16  10:55:50SocketChangeState, wsClosed -> wsOpened
2010-04-16  10:55:50TWSocket will connect to 200.255.94.90:2101
2010-04-16  10:55:50SocketChangeState, wsOpened -> wsConnecting
2010-04-16  10:55:50SocketChangeState, wsConnecting -> wsConnected
2010-04-16  10:55:50SocketSessionConnected, Socket operation on 
non-socket (#10038)
2010-04-16  10:55:5000D41210 TCustomWSocket.Shutdown 1 1472

Any ideas why it could happen?

-- 
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] Error "Socket operation on non-socket"

2010-04-16 Thread Anton Sviridov
>From time to time in my program I encounter strange error on connecting.
Here's a piece of socket log:

2010-04-16  10:55:50SocketChangeState, wsClosed -> wsOpened
2010-04-16  10:55:50TWSocket will connect to 200.255.94.90:2101
2010-04-16  10:55:50SocketChangeState, wsOpened -> wsConnecting
2010-04-16  10:55:50SocketChangeState, wsConnecting -> wsConnected
2010-04-16  10:55:50SocketSessionConnected, Socket operation on 
non-socket (#10038)
2010-04-16  10:55:5000D41210 TCustomWSocket.Shutdown 1 1472

Any ideas why it could happen?

-- 
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] Proper DataAvailable handling

2010-01-28 Thread Anton Sviridov
Thank you, Francois, wonderful answer, things are getting completely clear!

-- 
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] Proper DataAvailable handling

2010-01-28 Thread Anton Sviridov
Forgot to mention: the 2nd and 3rd snippets are for different purposes and are 
members of different classes.

-- 
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] Proper DataAvailable handling

2010-01-28 Thread Anton Sviridov
What is the proper way to handle TWSocket.DataAvailable?
I found this way in demo:

function TBinaryWSocket.TriggerDataAvailable(ErrCode: Word): Boolean;
var
Rcvd: Integer;
begin
Result := TRUE;
Rcvd := Receive(@FRcvBuf[FWriteOffs], (SizeOf(FRcvBuf) - FWriteOffs));
if Rcvd > 0 then
begin
Inc(FRemainingBytes, Rcvd);
Inc(FWriteOffs, Rcvd);
end;
if FRemainingBytes > 0 then
ParseReceiveBuffer;
end;

while I previously used such way:

procedure SocketDataAvailable(Sender: TObject; ErrCode: Word);
begin
if TWSocket(Sender).RcvdCount = 0 then Exit;
if ErrCode <> 0 then ; // do something
if FState in [csConnected, csRequesting, csReceivingInfo, csReceivingData] 
then
  if FEstablished
then SetState(csReceivingData)
else SetState(csReceivingInfo)
else try FSocket.Receive(@ShitBuf, SizeOf(ShitBuf)) except end;
  end;
end;

to check if there are data really available and to read everything from the 
socket in case of closing state or something else.
Today I decided to get rid of RcvdCount checking like this:

procedure DoDataAvailable(Sender: TObject; ErrCode: Word);
begin
if ErrCode <> 0 then
  Error(GetWinsockErr(ErrCode));

res := TWSocket(Sender).Receive(FCurrPtr, FDataNeeded);
if res < 0 then
begin
  Log('Error reading data: '+GetWinsockErr(WSocket_WSAGetLastError));
  Exit;
end;
Dec(FDataNeeded, res);
Inc(FCurrPtr, res);
if FDataNeeded > 0 then Exit;

end

but I found that Receive returns -1 with WSAEWOULDBLOCK error when 
DoDataAvailable is called with RcvdCount = 0.
So, the first question is: is it necessary to call method when no data 
available in fact, and the second: how to implement DataAvailable code in 
proper way? Is it possible for async Receive to returb some error besides 
WSAEWOULDBLOCK (i.e. do I need to check the error and report about it)?

Thanks in advance.

-- 
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] OT: IPv4 address shortage reaching critical stage

2010-01-21 Thread Anton Sviridov
Arno Garrels wrote:
> IMHO it's not very easy to keep backwards compatibility.

Maybe, but the question is what specifically should be done to make ICS support 
IPv6. On the component level all IP's are operated as strings - no problem 
here. Maybe you'll just need to implement a pair of new functions, for example, 
gethostaddr_v6 and that's all. So it's what I wish to now is what changes must 
be done. I searched yesterday, but found only general aspects.

P.S. But I've found that IPv6 is implemented even in XP!

--
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] OT: IPv4 address shortage reaching critical stage

2010-01-20 Thread Anton Sviridov
I wonder, what changes should be done to support IPv6. For now I see onlu few 
functions like gethostaddr etc, and some Socks5 stuff. This seems not very hard 
to implement (provided that new APIs appear).

--
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] FTPCli: RequestDone with ftpConnectAsync executed twice

2009-12-24 Thread Anton Sviridov
Very strange! I've traced DoHighLevelAsync step-by-step just now, and 
RequestDone was called only once, as it supposed to be. Moreover, then I 
launched my method without tracing and everything remained OK! I hadn't changed 
anything since I started this topic, so it's likely a piece of magic :)

-- 
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] FTPCli: RequestDone with ftpConnectAsync executed twice

2009-12-23 Thread Anton Sviridov
> Don't you just look at the RqType parameter in the event.

Yes, I do, and it is ftpConnectAsync in both cases.
Here's detailed event log:

Login OK!
FtpClient1RequestDone ConnectAsync ==> 1st time
< 220-Microsoft FTP Service
< 220 Hello, Welcome to the TrigNet ftp server
FtpClient1SessionConnected
> USER anonymous
< 331 Anonymous access allowed, send identity (e-mail name) as password.
> PASS gu...@unknown
< 230-Hi!
< 230 Anonymous user logged in.
> FEAT
< 211-FEAT
< SIZE
< MDTM
< 211 END
> SYST
< 215 Windows_NT
FtpClient1RequestDone ConnectAsync ==> 2nd time

-- 
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] FTPCli: RequestDone with ftpConnectAsync executed twice

2009-12-23 Thread Anton Sviridov
Hello!
I've found that when connecting RequestDone is executed twice with FRequestType 
= ftpConnectAsync.
I use the following command to login:

HighLevelAsync(ftpConnectAsync, [ftpFctOpen, ftpFctAuth, ftpFctUser, 
ftpFctPass, ftpFctAcct, ftpFctSyst, ftpFctFeat]);

and RequestDone is called 1st time when connection to server is established, 
and 2nd time when all requests up to FEAT are sent and answered.
My question: is there a way to distinguish these two cases from within 
WMFtpRequestDone?

-- 
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] Missing part & suggestion to FTPClient

2009-12-18 Thread Anton Sviridov
>What code is forgotten?  FEAT sync and async both work fine. 
I mean code in DoHighLevelAsync, that is, pushing ftpFctFeat into 
HighLevelAsync does no matter.

>If you think new methods are needed, you need <...>
Hmm, quite complicated. Okay, I'll do it some time later.

-- 
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] Missing part & suggestion to FTPClient

2009-12-18 Thread Anton Sviridov
>Sync FEAT works as well, I use it hundreds of times per day.
Yes, I know, but I do async operations, and implemented my own Login method 
which executes all initialization stuff, including SYST and FEAT so that all of 
these commands are packed into single request. Anyway, I think the code should 
be added anyway, because it's likely a forgotten piece.

I'd also like to suggest to add virtual TriggerResponse method which will 
launch OnResponse by default, but allow overriding in descendants. It will be 
very convenient for custom response processing, leaving event for end-users to 
assign.

--
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] Missing part & suggestion to FTPClient

2009-12-18 Thread Anton Sviridov
Sorry, I've messed things up. The missing request is FEAT.

-- 
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] Missing part & suggestion to FTPClient

2009-12-18 Thread Anton Sviridov
Hello!
There's missing part in DoHighLevelAsync - it can't handle ftpFctSyst request. 
Here's what should be added:

if ftpFctSyst in FFctSet then begin
FFctPrv := ftpFctSyst;
FFctSet := FFctSet - [FFctPrv];
SystAsync;
Exit;
end;

And another thing: I suggest some way to redetermine socket class used in 
client - maybe through SocketClass property, maybe through virtual CreateSocket 
function. The goal is to use custom extended versions of TWSocket. What I've 
done for my project is
functionCreateSocket: TWSocket; virtual;

in constructor
FControlSocket  := CreateSocket;
FDataSocket   := CreateSocket;

and redefined this method in FTPCli descendant.

-- 
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] NO_ADV_MT and Multithreaded application

2009-12-16 Thread Anton Sviridov
Arno, SZ, thanks for your answers!
Idea of removing some CritSections looks nice, as these sections, I suppose, 
are unnecessary. This will surely increase overall performance.

-- 
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] NO_ADV_MT and Multithreaded application

2009-12-09 Thread Anton Sviridov
Arno,
so your advice is to leave everything as it is?

--
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] NO_ADV_MT and Multithreaded application

2009-12-08 Thread Anton Sviridov
>ADV_MT enabled (i.e., NO_ADV_MT defined)

I mean, ADV_MT disabled (i.e., NO_ADV_MT defined)

-- 
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] Use of twsocket in thttpserver application

2009-12-08 Thread Anton Sviridov
Hello Chris,
I've wrote simple descendant of TWSocket which implements timeout stuff 
internally, I could send you the unit if you are interested

-- 
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] NO_ADV_MT and Multithreaded application

2009-12-08 Thread Anton Sviridov
Hello!
I'm writing multithreaded VCL application with following structure:
- one thread holding a number of sockets receiving data
- one server thread to provide remote control
- one main TApplication thread, of course
All actions with sockets are done within their owner thread.

All inter-thread stuff is synchronized by events, PostMessage is used where 
possible, so I think no issues here.

The question: do I need ADV_MT enabled (i.e., NO_ADV_MT defined)? It generates 
lots of locking/unlocking, which I think are excess in my case. Or it's safer 
to leave the define as is?

Thanks in advance.

-- 
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] [TWSocket] Code proposals

2009-12-04 Thread Anton Sviridov
Francois,

>Don't get me wrong, I really appreciate your suggestions to improve ICS. If 
>you see the history in each source file, you'll see the large number of 
>contributors.

I got your point, but I really wonder, what kind of suggestions will you accept 
if:
1) small internal changes you don't like because version comparing becomes more 
sophisticated
2) medium changes will break the existing code and thus rejected
3) large changes will also break code, and not necessary so one should derive 
his own class and there implement everything he wishes

Not criticising, just curious. I'd like to know it when I'll be going to post 
some other proposals :)

--
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] [TWSocket] Code proposals

2009-12-02 Thread Anton Sviridov
>This is an "and" not an "or". The exception is raised when FProtoStr is 
>neither 'tcp' no '6'.
Aaaah, yeah, I got it. Seems my mind was too sleepy yesterday ;)

>Probably. Maybe you'll implement those features ?
I could make a try when I have some time, but it will be a kind of sketch 
anyway, as I hadn't fully realised TWSocket processes and ideology yet.

>Shorter in code, but slower.
Is it?

procedure Function1;
var o: tobject;
begin
  o := tobject.Create;
  o.Free;
  o:=nil;
  if o <> nil then error(''); // use o to not let the compiler eliminate 
previous line
end;

procedure Function2;
var o: tobject;
begin
  o := tobject.Create;
  FreeAndNil(o);
  if o <> nil then error('');
end;

on 500 iterations I got these results (3 tests were done):
875 - 860
890 - 844
875 - 844
the values are in millisecs! So the difference is about 2 nanosec per one call 
:)

>Note that this has been written at a timle where FreeAndNil didn't existed.
This reason I get indeed, but it's time to move on, no?

>The problem is that is would break existing code. On of the gold rules in 
>ICS has always been and will always be to avoid as much as possible breaking 
>existing code. The error message, if required, should be passed thru a 
>property for example. This wouldn't break any existing code.
Of course, it is you to decide, but I don't see big troubles in some 
improvements even if they would break some code (break syntatically, but not 
logically!) - one will simply edit few lines and that's all. And you are 
prisoning the project into a cage of old class interface, having to invent lots 
of workarounds or to cancel further improvements because they will break... do 
you really think it's what it should be? (everything's *imho*).

--
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] [TWSocket] Code proposals

2009-12-01 Thread Anton Sviridov
>When Unicode Delphi came out the goal was to port ICS with minimum
>changes, I guess the same was true when Delphi .Net came out.
No argues, but sometimes the things done in hurry should be polished, shouldn't 
they?

About .Net: I see that it's in eraly development stage, so let it go as you 
wish, it's all the same to me as I don't use .Net.

>It's not a mistake but simply backwards compatible.
>I did not find anything in RFC of how to handle
>non-ASCII chars with socks authentication, did you? 
I've read http://www.faqs.org/rfcs/rfc1929.html, but hadn't found anything 
about codepage, maybe it depends on implementation, whether server allows 
Unicode login or not.

And now few more remarks:

1)  in IcsWSocket

if (_LowerCase(FProtoStr) <> 'tcp') and (_Trim(FProtoStr) <> '6') then begin
RaiseException('TCP is the only protocol supported thru socks server'); 
{ V5.26 }
Exit;
end;

   a) looks quite weird, as it likely to throw exception in every case 
(FProtoStr can't be equal to 'tcp' and '6' at the same time)
   b) UDP through Socks5 is possible through UDP ASSOCIATE command instead of 
CONNECT, as well as listening is available through BIND command

2)
begin
FBufHandler.Free;
FBufHandler := nil;
end;

=> FreeAndNil ? Much shorter

3)
TriggerError  { Should be modified to pass Msg ! }

it really should be :)

--
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] [TWSocket] Code proposals

2009-11-23 Thread Anton Sviridov
And even more:

1)
procedure TCustomSocksWSocket.SetSocksServer(sServer : String);
begin
...

if Length(FSocksServer) = 0 then begin
FSocksServerAssigned := FALSE;
Exit;
end;
FSocksServerAssigned := TRUE;
end;

=>

FSocksServerAssigned := Length(FSocksServer) <> 0;

and the same with the port

2)
function TCustomSocksWSocket.GetSocksServer: String;
begin
Result := FSocksServer;
end;

=>

property read FSocksServer ? The same with SocksPort, TWSocket.RemotePort, 

3)
Strange principle of defines in constructors:

in TWSocket
{$IFDEF CLR}
constructor Create{$IFDEF VCL}(AOwner : TComponent){$ENDIF}; override;
{$ENDIF}
{$IFDEF WIN32}
constructor Create(AOwner: TComponent); override;
{$ENDIF}

but in TCustomSocksWSocket
  constructor Create{$IFDEF VCL}(AOwner : TComponent){$ENDIF}; override;

the latter seems much nicer.

4)
functionTimerIsSet(var tvp : TTimeVal) : Boolean; virtual;
procedure   TimerClear(var tvp : TTimeVal); virtual;
functionTimerCmp(var tvp : TTimeVal; var uvp : TTimeVal; IsEqual : 
Boolean) : Boolean; virtual;

What for these methods? They aint't used by anywhere in the ICS

5)
wsSocksConnected seems deprecated, why not remove it from declaration?

-- 
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] [TWSocket] Code proposals

2009-11-23 Thread Anton Sviridov
Having looked at the OverbyteIcsWSocket unit, I've noticed many IFDEF CLR which 
probably might be removed.

First of all, I think it's better to turn all buffers from PAnsiChar / array of 
AnsiChar to TBytes, as it is recommended by Embarcadero (though one would 
declare this type for compilers up to BDS2006).

Second, I see numerous cases of copying by for loops in CLR code, while on 
WIN32 it's done by Move. I also noticed System.Buffer.BlockCopy(FRcvdPtr, 0, 
Buffer, 0, FLineLength); in just one place instead of for loop, maybe this 
function should be used? Moreover, when copy from string to buffer is done, 
like here:

procedure TCustomWSocket.PutStringInSendBuffer(const Str : RawByteString);
{$IFDEF CLR}
var
Data : TBytes;
I: Integer;
begin
SetLength(Data, Length(Str));
for I := 1 to Length(Str) do
Data[I - 1] := Ord(Str[I]);
PutDataInSendBuffer(Data, Length(Str));
{$ENDIF}

why not use Str.GetBytes method? (I suppose it to be realised in .Net from the 
very beginning)

Another places where I discovered possibly non-optimal defines:

1)

{$IFDEF CLR}
  TSockAddr  = OverbyteIcsWinSock.TSockAddr;  
{$ENDIF}
{$IFDEF WIN32}
  TSockAddr  = OverbyteIcsWinsock.TSockAddr;
ip_mreq = record
imr_multiaddr : in_addr;
imr_interface : in_addr;
end;
{$ENDIF}

=>

  TSockAddr  = OverbyteIcsWinSock.TSockAddr;  
{$IFDEF WIN32}
ip_mreq = record
imr_multiaddr : in_addr;
imr_interface : in_addr;
end;
{$ENDIF} ?

2)
functionSend({$IFDEF CLR} const {$ENDIF} Data : TWSocketData; Len : 
Integer) : Integer; overload; virtual;
and
functionSendTo(Dest   : TSockAddr;
   DestLen: Integer;
   {$IFDEF CLR} const {$ENDIF} Data : TWSocketData;
   Len: Integer) : Integer; virtual;

why not declare it const for all platforms?

3)
in WSocket_accept there's too much conditions, even for D1 - I thought D1-D6 is 
unsupported in v7 ?

Some other remarks:

4)
function AddOptions(Opts: array of TWSocketOption): TWSocketOptions;
Result := Result + [Opts[I]];
=> 
Include(Result, Opts[I]);
as it is faster

5)
function  RemoveOption(
Result := OptSet - [Opt];
=> 
Exclude(Result, Opt);
the same

6) (possibly bug)
for I := Low(LocalSockName.sin_zero) to High(LocalSockName.sin_zero) do
LocalSockName.sin_zero[0] := #0;

LocalSockName.sin_zero[i] ?

7)
procedure TCustomSocksWSocket.SocksDoAuthenticate;
TempS  := AnsiString(FSocksPassword);
TempS  := AnsiString(FSocksUsercode);

Looks like one couldn't use Unicode characters in Socks login? Is it mistake or 
protocol restriction?


8)
Phe := PHostent(@FDnsLookupBuffer);
if phe <> nil then begin

Phe currently never could be nil, as FDnsLookupBuffer is declared as static 
array field

Of course, these are just small proposals, and I probably haven't taken into 
account some deep relations or something else, so please don't judge me too 
strictly.

--
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] Future plans of ICS

2009-11-18 Thread Anton Sviridov
Francois, thanks for answer.

1) Ok, I've got your point.

2) I see your point in this too, but you could add some helping thigs like 
those I suggested, aren't you?

--
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] Future plans of ICS

2009-11-18 Thread Anton Sviridov
Angus,
I know and have already looked into the code, and even tryed to understand it :)
But as you've mentioned it's not trivial to grab parsing code out of the 
component because of lots custom routines used.
And I'm talking of slightly another thing: a standard and native ICS interface 
for parsing. For instance:

ftp.Feat() // get feats, determine whether server supports MLST, or MDTM, or 
anything related
...
ftp.GetListing(RemoteDir) -> ftp.List(RemoteDir) -> get listing into 
ListingStream -> convert it to ListingStringList -> invoke OnFtpListingParse

not very hard as I see it, but make it easy for others to implement parsing 
function.

But of course, merging Magenta's parsing into ICS would be much more helpful 
and useful.

>Full FTP parsing is implemented in TMagFtp, which is a high level version
>of TFtpClient, you can use the entire unit or borrow
>TMagFtp.UnpackFtpFDir (which has a lot of dependencies).  

-- 
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] Future plans of ICS

2009-11-18 Thread Anton Sviridov
I have a couple of questions about future of ICS.
1) FPC port. Will it continue someday? Or maybe just Linux support (according 
to Emb's roadmap to bring something like Kylix to life someday)?

2) Parse listings in FTP client. I do not ask for parsing implementation (as I 
understood, you don't feel doing it), but a kind of general workaround, like 
OnParse event, internal getting listing to TStringList, and so on. Think it 
would be helpful and not dealing with not standartized things which you don't 
like.

--
Regards, 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] Timeout in sync operations

2009-09-17 Thread Anton Sviridov
> Connect-timeouts are not the only possible ones.
Yes, I know, but connect ones are the most general and used by everyone, 
because w/o connection there's nothing to do anyway.

> If you need different timeout values for different states it has to be
> implemented using a timer. We need to keep the message pump
> as fast as possible.
But what about convenience? And every programmer implements these timeouts 
anyway. Or he hopes on ICS and doesnt do this receiving endless connect 
waiting...

>Actually it _is called on StateChange(httpReady).
Yes, but it is called with ErrCode = 0 and StatusCode = 0. Also I have strange 
things here:

log of my program, trying to download http://test1.ru/1.php, which is my script 
with endless loop to simulate timeout:

 URL http://test1.ru/1.php : retrieving header... (attempt 1/3) // 
FHttpCli.Head called
tick... 1 // this from my timer, which does nothing but counting
tick... 2
tick... 3
tick... 4
tick... 5
Error: HEAD Failed (404, Request aborted on timeout)! // exception from Head, 
everything's OK
 URL http://test1.ru/1.php : retrieving header... (attempt 2/3) // 
FHttpCli.Head called 2nd time
Done.// HttpRequestDone with ErrCode = 0!
Done.// HttpRequestDone with ErrCode = 0!
Header received, StatusCode = 0 // Head successfully passed!

with my timer everything's OK:

 URL http://test1.ru/1.php : retrieving header... (attempt 1/3)
tick... 1
tick... 2
tick... 3
tick... 4
tick... 5
Failed, error #3
Error: HEAD Failed (404, Connection aborted on request)!
 URL http://test1.ru/1.php : retrieving header... (attempt 2/3)
tick... 1
tick... 2
tick... 3
tick... 4
tick... 5
Failed, error #3
Error: HEAD Failed (404, Connection aborted on request)!
 URL http://test1.ru/1.php : retrieving header... (attempt 3/3)
tick... 2
tick... 3
tick... 4
tick... 5
Failed, error #3
Error: HEAD Failed (404, Connection aborted on request)!
*** finish ***

*

BTW, I have noticed that Last-Modified filed in header isn't parsed! IMHO it's 
too important field to leave parsing of it. Maybe Magenta's code could be added 
for this purpose?

-- 
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] Timeout in sync operations

2009-09-17 Thread Anton Sviridov
>Any alternates (http://en.wikipedia.org/wiki/List_of_HTTP_status_codes)? 
>It's not a constant error AFAIK. IMO 408 was more confusing. 

Yeah, that's why transport level stuff should be done in transport (socket) 
classes :) We would have OnConnect(Request)Timeout or something like and no 
mess with statuses...

>OK, what about this one?

That's pretty better, although OnRequestDone is never called and hence 
FRequestDoneError isn't used. Maybe make it readable property?

-- 
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] Timeout in sync operations

2009-09-17 Thread Anton Sviridov
Arno Garrels wrote
>TWSocketCounter has been added to TWSocket in V7 with properties 
>ConnectTick, ConnectDT, LastAliveTick, LastRecvTick and LastSendTick.
Yes, I'm using it in my FTP class, but Start/StopTimer seem easier in my case

SZ wrote:
>I think Arno and Francois is right about not making a TTimer per Thttpcli as
>default. It would overwhelm our reverse proxy with 10k connections each with
>two sockets. However for simple needs, Anton is right about asking for a
>solution which I think sould only be switched on by a define.
The timer could be created only by special call, like it's done for Counters... 
also there are no such necessary in timers in server components, they are 
content with a single one to trace inactive connections. And I doubt that 
anybody will have so much client sockets that he'll run out of Windows 
resources.

Arno Garrels wrote
>Please guys, take a look at this fix for V7 and test it, anything wrong
>with it?
It works, but I think Abort isn'tt a very good way to tell that there was 
timeout... and 404 even stranger. 404 means that file not exist (constant 
error), "Connection aborted on request" means that user or control proc decided 
to break the waiting, and timeout means that there's no answer from server and 
we should wait and retry later.

-- 
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] Timeout in sync operations

2009-09-16 Thread Anton Sviridov
>If you build a console mode application, you have to create one yourself. 
>See various console mode ICS d?mos. Simple...
Yes, I created TIcsTimer with HttpCli.CtrlSocket as Owner and implemented 
Start/StopTimer methods. Seems working, although I don't see yet how can I 
control the main function flow from OnTimer procedure (i.e., how to tell 
CtrlSocket that is's timeout).

>This is underway. but designing a general purpose timeout is not so simple 
>because you potentially have thousands of components (server side). You 
>can't create a TTimer for each one or you'll run out Windows resources very 
>quickly (bad scalability).
No problem, you could implement only one timer in the very root of socket (as 
you did with socket's window handle, AFAIR).

>Currently you should implement a timeout yourself. Using a single TTimer and 
>carefully crafted code will do the job
Yeah, and every developer should do the same, so we are inventing the bicycle 
again. Maybe then some general TTimeoutOperationsSeeker? Anyway, at least for 
connection stage timeouts should be implemented, imho.

-- 
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] Timeout in sync operations

2009-09-16 Thread Anton Sviridov
> how can I add timeouts without messageloops and threads and so on?
I see that there is still ControlSocket.MesagePump in SyncRequest, so I suppose 
creating timer will work, won't it?

-- 
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] Timeout in sync operations

2009-09-16 Thread Anton Sviridov
Hello!
I'm writing simple console downloader and decided to use sync operations in 
order to simplify structure. But I've found that sync requests (HttpCli) do not 
use any timeout, so they may last forever in case of error. My question is: how 
can I add timeouts without messageloops and threads and so on?

And second question, more global: Isn't it worth to add good and native timeout 
functionality to TWSocket so that thousands of developers hadn't invent a 
bicycle again and again? I know about TIcsTimer and so on, but it is not 'out 
of the box'.

-- 
Best regards, 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] Error handling in FTPcli

2009-06-09 Thread Anton Sviridov
Thank you Angus, I'll look at the code more intently. To take your component 
isn't appropriate for me, as I want multiple connections without threads.

-- 
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] Error handling in FTPcli

2009-06-08 Thread Anton Sviridov
Hello everyone, nobody answered me in old topic, so I'll start a new one.
I really wonder, what the concept of FTPcli's error hadling/reporting is. Some 
critical errors, such as exception during creation of local file, are reported 
as FTP error codes. So, how I could handle them in a right way - you don't mean 
coder to analyse error message strings, don't you? As for me, the exceptions 
would be more appropriate to tell that something's wrong on our side, and let 
FTP error codes to report remote errrors only. Anyway, I'll welcome any 
explanations of how could I handle various errors in FTPcli working progress.

-- 
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] TWSocket stops receiving where TClientSocket just keeps going

2009-06-05 Thread Anton Sviridov
Maybe you should create an exception handler by assigning OnBgException event - 
unhandled excepion is the frequent reason of strange behaviors in async 
applications. You can also indeed sniff the data transferred - I recommend 
SmSniff, which is as simple as it could be.

-- 
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 questions about FTPCli

2009-05-27 Thread Anton Sviridov
Another new questions, using existing topic.
It's concerning error handling in FTPCli. I see that many local errors, such as 
exception when opening local stream, are converted into ftp error messages. How 
do I handle them (for example, I want to track file creation errors)? And 
another question - is returning of ftp code the one way of error reporting, or 
there's some exceptions raised?

--
Regards, 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 questions about FTPCli

2009-05-26 Thread Anton Sviridov
Angus, I haven't found OnRetrSessionClosed in OverbyteIcsFtpCli.pas, are you 
sure it's the right name?
I have file with following latest update in history:

Apr 16, 2009 V7.07 Angus assume STREAM64, USE_MODEZ, USE_ONPROGRESS64_ONLY, 
USE_BUFFERED_STREAM
 Remove old conditional and suppressed code, OnProgress gone 
(BREAKING CHANGE)

--
Regards, 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 questions about FTPCli

2009-05-26 Thread Anton Sviridov
>Which SVN ? You have ICS-V5, ICS-V6 and ICS-V7. Latest code is in ICS-V7.
Hmm. Version 7 points that it's ICS 7, doesn't it? Unit from 
\SVN\OverbyteIcsV6\ics\branches\icsv7\Delphi\Vc32

--
Regards, 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 questions about FTPCli

2009-05-26 Thread Anton Sviridov
>Probably historical, over the years the code gets standarised and
>simplified if possible, but sometimes old bits get left behind. 
So, these bits will be sometime replaced by new ones?

>Exactly what internal version are you looking at, at the top of the unit,
>only v7.08 and later are getting fixes. 
const
  FtpCliVersion  = 707;
just now updated from SVN. Where I can find the v7.08?

>OnRetrSessionClosed
Thanks, I'll try it!

--
Regards, 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] Two questions about FTPCli

2009-05-25 Thread Anton Sviridov
1) The destroying of FLocalStream is widely used as
if Assigned(FLocalStream) then begin
FLocalStream.Destroy;
FLocalStream := nil;
end;
but there's also a specific method DestroyLocalStream, what's the difference? 
Maybe it would be better to use DestroyLocalStream everywhere?

2) I'm searching, but cannot find where the event of complete file downloading 
is located (I want some actions on newly got file). Could someone show me the 
place?

Thanks in advance, 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] TIcsLogger proposal

2009-05-09 Thread Anton Sviridov
Arno, if you care about "slowing" string concatenations (although concatenation 
will be executed *anyway*: Time+Sep+Msg), then we could do something like this:

FDateFormat, FTimeFormat, FDateTimeFormat: string;
...
procedure SetDateTimeFormat(df, tf: string);
begin
  FDateFormat := df;
  FTimeFormat := tf;
  FDateTimeFormat := FDateFormat + FLogSep + FTimeFormat;
end;

and

procedure SetLogSep(ls: char);
begin
  FLogSep := ls;
  FDateTimeFormat := FDateFormat + FLogSep + FTimeFormat;
end;

- two methods are used to implement independence between format strings and log 
sep. Or, we really could just set DateTimeFormat as single string, not taking 
care about a separator between date and time. But also you should do something 
with code for .NET, to make output configurable too.
I sent Francois my modification of unit, it of course isn't ideal, but it's 
something to start from. Also there is a check of CR/LF in the end of logged 
line, to avoid doubling of these characters when Msg already contains them (FTP 
server responses, for example).

--
Regards, 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] TIcsLogger proposal

2009-05-07 Thread Anton Sviridov
Francois, you're right, properties will go better. I'll be waiting for updates 
of Logger in SVN =)

--
Regards, 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] TIcsLogger proposal

2009-05-06 Thread Anton Sviridov
I have a little suggestion to improve TIcsLogger. The reason is that I wish to 
have both date and time in logfile and don't care about millisecs.
Also, I don't want to derive classes, override events and all that stuff, just 
want to make output format customizable.

1) add public variable

var TimeStampPattern: string = 'hh:nn:ss:zzz';

2) line
DateTimeToString(Result, TimeStampPattern, Time);
change to
DateTimeToString(Result, TimeStampPattern, Now);

3) add piblic variable
LogSep: Char = ' ';

4) in DoDebugLog replace ' ' by LogSep

So in our Form we could do this:

FormCreate()
begin
  TimeStampPattern := '/mm/dd'#9'hh:nn:ss';
  LogSep := #9;
end;

and get logfiles with easy-to-recognize columns with data, time and message 
fields.

Also there's something to change in adding the new line symbols in case when 
message already contains them.

--
Regards, 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] Using timeouts

2009-04-24 Thread Anton Sviridov
I have discovered some stuff dealing with socket timeouts and wish to know how 
to apply them
These are TWSocketCounter and TFtpClient.Timeout. As far as I see, the former 
one just stores timestamps of recent socket activities, but does nothing if 
there are no activity for a long time. And the latter seems only to be used in 
WaitUntilReady. Am I right and there's no more means of tracking connect or 
read timeouts?

--
Best wishes, 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] MboxProxy available for download

2009-02-19 Thread Anton Sviridov
Interesting stuff, but your site looks down...

--
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] Freeware HTTP/HTTPS proxy server for testingauthentication stuff

2009-01-11 Thread Anton Sviridov
3proxy (http://3proxy.ru/board/?l=EN)
Console app with manually edited conf files, but in part of auth settings are 
quite simple

--
Regards, 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] Mailing list usage

2008-12-18 Thread Anton Sviridov
Could someone explain how to set Opera to receive messages from this list? Not 
through my mailbox but as Newsgroups. If this possible, I'll need incoming and 
outgoing addresses,

--
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] WriteCount property proposal

2008-12-17 Thread Anton Sviridov
I just thought: why not implement a sent data counter as it's done with 
ReadCount? It would be rather useful for sockets on the servers, for example.

--
Regards, 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] Mailing list usage

2008-12-17 Thread Anton Sviridov
>Only for lazy people that attach the entire previous message including
>all the unsubscribe information.

http://lists.elists.org/pipermail/twsocket/2008-December/039307.html

So Arno is lazy? :)

>But most forums I see also include massive quoting, and show entire
>threads on a single page, so you have to scroll past all the messages
>you've seen before to see is anyone has added a comment.  So you waste
>hours and hours looking for new messages, unlike a decent email client
>that allows each new email message to be seen by a simple CR key.   Ditto
>a decent NNTP reader.   So I rarely read any web forums. 

Yes, there are people who use to overquote posts though it's usually a 
forbidden thing on most forums. I hate them :) But what's the goal of quoting? 
To track discussion in a mess of tens various topics, as now. But in forums 
topics are already divided, and when you open topic, you see all previous 
messages, so there is no need of quotes or they can be small. New messages? All 
forum implementations allow "Unread messages" feature - you see which posts you 
haven't read. Moreover, there is one pretty good thing like RSS, which allows 
to be always informed about new messages.

And another argument: if I wish to save the whole thread, what should I do now? 
Download archive, select needed messages and merge it by hands?

--
Regards, 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] Mailing list usage

2008-12-17 Thread Anton Sviridov
Of course it's just my imho, but wouldn't it better to switch to modern 
technologies like message boards/forums? Nailing list... forgive me, but it's 
an ancient ages stuff. Main inconvenience is a huge quotations in each mail, 
and the further in discussion, the larger they grow, sometimes including 3 or 4 
mails! So the digest becomes terrifying, and hard to read new info.
Another trouble is answering - as for me, I only receive digest, so I couldn't 
just press "Reply", I am compelled to copy-paste each sentence and it is really 
tiring work.

--
Best regards, 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] Multiple OnDataAvailable calls when no data to read

2008-12-02 Thread Anton Sviridov
Arno, thank you for answering! Sorry I wrote directly, I completely forgot that 
new month has come and Archives are on the new page.

> In mode rmBinary OnBinaryReceived will trigger. Data move is left
> to the component user. 

I was looking on that buffer code and even started to implement separate buffer 
class, but discovered that TIcsBuffer has been already realized all necessary 
functions! Now it's used only for buffering output data, but I'm sure it's the 
one I need. 

--
Regards, 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] Multiple OnDataAvailable calls when no data to read

2008-12-01 Thread Anton Sviridov
> Arno Garrels [TeamICS] wrote:
>Have a look at this demo, if you think it's usefull I can add it to the
>repository.

Oh, I am looking at this and get myself full of questions. Server app is rather 
clear, but not the Client, it's quite complex.

1) What's the meainng of SendBinString in Server, it is never used? What for do 
you use PutDataInSendBuffer?
2) I see alot of code to implement a data buffer which imho does the same 
things that socket buffer do. Isn't it necessary to construct such 
sophisticated logic every time when data parsing is needed?
Moreover (maybe I haven't detected) what do you do, if FRcvBuf is going to be 
filled? That is,

FRcvBuf: [_] [_] [_] [_] [D] [D] [D]
  |
[_] - already parsed data
[D] - data to be parsed
| - current pointer

and there are some more bytes to be received, but buffer is over... I've found 
only one Move(), but it's located inside if FReceiveMode = rmLine section, but 
no copying is done when mode is binary.

Maybe it would be a good idea to implement this buffer internally in TWSocket? 
Just to have a solid way to know how mush data is available now.

3)  if FReceiveMode = rmLine then
begin
  ...
end;

if FReceiveMode <> rmBinary then
Exit;

strange construction, concerning that FReceiveMode could be only rmLine or 
rmBinary... maybe if..else ?

4)  while (Length(RcvdLine) > 0) and
  (RcvdLine[Length(RcvdLine)] in [#13, #10]) do
RcvdLine := Copy(RcvdLine, 1, Length(RcvdLine) - 1);

while (Length(RcvdLine) > 0) and
  (RcvdLine[Length(RcvdLine)] in [#13, #10]) do
SetLength(RcvdLine, Length(RcvdLine) - 1); ?

--
Best regards, 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] Multiple OnDataAvailable calls when no data to read

2008-12-01 Thread Anton Sviridov
> Arno Garrels [TeamICS] wrote:
>Have a look at this demo, if you think it's usefull I can add it to the
>repository.

Oh, I am looking at this and get myself full of questions. Server app is rather 
clear, but not the Client, it's quite complex.

1) What's the meainng of SendBinString in Server, it is never used? What for do 
you use PutDataInSendBuffer?
2) I see alot of code to implement a data buffer which imho does the same 
things that socket buffer do. Isn't it necessary to construct such 
sophisticated logic every time when data parsing is needed?
Moreover (maybe I haven't detected) what do you do, if FRcvBuf is going to be 
filled? That is,

FRcvBuf: [_] [_] [_] [_] [D] [D] [D]
  |
[_] - already parsed data
[D] - data to be parsed
| - current pointer

and there are some more bytes to be received, but buffer is over... I've found 
only one Move(), but it's located inside if FReceiveMode = rmLine section, but 
no copying is done when mode is binary.

Maybe it would be a good idea to implement this buffer internally in TWSocket? 
Just to have a solid way to know how mush data is available now.

3)  if FReceiveMode = rmLine then
begin
  ...
end;

if FReceiveMode <> rmBinary then
Exit;

strange construction, concerning that FReceiveMode could be only rmLine or 
rmBinary... maybe if..else ?

4)  while (Length(RcvdLine) > 0) and
  (RcvdLine[Length(RcvdLine)] in [#13, #10]) do
RcvdLine := Copy(RcvdLine, 1, Length(RcvdLine) - 1);

while (Length(RcvdLine) > 0) and
  (RcvdLine[Length(RcvdLine)] in [#13, #10]) do
SetLength(RcvdLine, Length(RcvdLine) - 1); ?

--
Best regards, 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] Multiple OnDataAvailable calls when no data to read

2008-11-26 Thread Anton Sviridov
Arno Garrels [TeamICS] wrote:
>AFAIK no, only if you do not read all available data OnDataAvailable 
>will trigger again.

Arno Garrels [TeamICS] wrote:
>Thus calling Receive multiple times
>in a loop in on DataAvailable would not work properly.

*embarrassed* how these two statements combine? Why several Receives should 
cause troubles?

And another question. Is TWSocket.RcvdCount value reliable, i.e. if it = 0, 
then there is really no data in the socket?

--
Best regards, 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] Multiple OnDataAvailable calls when no data to read

2008-11-25 Thread Anton Sviridov
Hello, Wilfried!
You have calmed me :)

Arno Garrels [TeamICS] wrote:
>As I understand the OP calls receive multiple times in OnDataAvailable
>which is not a good idea.

So, each Recv "launches" one more OnDataAvail in the future? If so, can I 
easily read from socket block-by-block? Here's what i do for now:

 ...
  // look for first byte of message start signature
  repeat res := Receive(@tmpC,SizeOf(tmpC)) until (res<=0) or 
(tmpC=MsgBeg[1]);
  if res <= 0 then Exit;
  // check if the following bytes are really message start
  for tmpI := 2 to Length(MsgBeg) do
if (Receive(@tmpC,SizeOf(tmpC))<=0) or (tmpC <> MsgBeg[tmpI]) then Exit;
  // get message type
  res := Receive(@tmpI,SizeOf(tmpI));
  // all OK, start receiving message
  FMsgType := TMsgType(tmpI);
  FInsideMsg := True;
  FBytesToRead := MsgLengths[FMsgType];
 end

Should I create a state variable and do every receive in separate execution of 
OnDataAvail ?

--
Best regards, 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] Multiple OnDataAvailable calls when no data to read

2008-11-25 Thread Anton Sviridov
I'm now implementing a server on the base of TWSocketServer. In the client app 
I send some message to the server app, which receives it inside 
ServerIn_ClientDataAvailable procedure. Receiving is realized step by step to 
find a signature of message - i.e., there are several client.Receive in the 
method.
I faced with strange thing: after whole message is read (and no data is sent 
yet), client's OnDataAvailable is executed some more times. 
TMsgReceiveSocket(Sender).RcvdCount returns 0, and Receive returns -1 with 
error code "Would block". So the question: why OnDataAvailable is executed when 
there is actually no data to be read?

--
Best regards, 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] I wan't to stop the server from listening then start it

2008-11-01 Thread Anton Sviridov
Francois, thank you for packages advise. It is quite unulual but looks 
convenient.

> You don't need to change the FTP component or any other else. It takes careof 
> everything. You should only change TWSocket because you don't want to dothe 
> initi in your application.
So, suppose I inherit a class
TNewTWSocket = class (TWSocket)
...
AssignDefValues
...
end

I don't see how this would affect on TFtpCli which I use

> You should not disable a "strange method" unless you fully understand whatit 
> does and if it is not used elsewhere. You can of course disable it foryour 
> own applications or components but surely not for existing applicationsor 
> components. If you do, you'llk probably break something because 
> theapplications or components are developped assuming the behaviour 
> youconsider "strange".

I looked at the sources, and decided that it is safe to remove field clearing. 
Of course this modifications will be for my own apps only, and so on.

> Clearly here, the "strange method" is not a bug. It is a feature. By 
> designTWSocket reset some properties to default values. There is a good 
> reasonbehind that design, even if that reason is no more really applicable 
> today,that behaviour must be preserved because existing code may rely on it.

Obviously it is. Bugs look differently)). But I can find no reasons for that 
and consider such behavior very embarassing. I have never ever saw a class 
where programmer has to re-assign fields he already assigned before.

> As a side note: When you think something must be changed in ICS 
> components,then sublit your proposal here, explain why your change is needed, 
> eitheradding a new feature or fixing an issue, and let's discuss it. If it 
> isapproved, then your change will be done in the component for everyone. 
> Onegold rule with ICS is "do not break existing code unless really 
> reallyreally needed".

Yes, I've already reported 
(http://lists.elists.org/pipermail/twsocket/2008-August/038568.html) about it 
when I nearly chashed my brain on this underwater stone. First time connection 
establishes OK, but second time it fails, wth? I've lost hours before I found 
the trouble source.

Moreover. Another head-breaking bug-or-feature: necessity to manually specify 
binary or text mode. Also many hours of step-by-step debug. to find an answer 
why received files are broken. I reported about it, but was said that I should 
implement mode selection by myself.

Another issues:
*  External FLocalStream issue, when FTPCli destroys an object which it didn't 
create.
*  Unuseful host name resolving when using socks5
- these things I've reported too, but got no reaction. So what's the meaning of 
further reporting about exceptions in log and received file creation if 
directory doesn't exist, great lack of timeout mechanism for stopping socket 
from waiting eternally, and so on? Looks like I have to implement all needed 
behaviors by my own.

--
Regards, 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] I wan't to stop the server from listening then start it

2008-11-01 Thread Anton Sviridov
> You do not need to "redeclare" the properties; all
> you need to do is override the AssignDefaultValue()
> method, like Francois said.
In FTP client, there are two fields of type TWSocket. Whose AssignDefaultValue 
should I override to stop them from clearing properties?

> This method is virtual for precisely this reason.
Actually I still can't understand for which reason this method was made

> But, in general: yes, that's exactly what you should do.
Sorry, but i dont' wish to do all that things just for disabling a single 
strange method.

> Also, keep in mind that you do not necessarily have
> to install your custom components into the IDE; you
> can very well instantiate any component by calling
> it's constructor directly.  Of course, you will not
> be able to "drop" the component on a form, but
> sometimes this is not a big deal.
They are components, right? Components are intended to be inited in design-time.
As for me, I create ICS objects in run-time, but in general inheritance of 
visual components is very, very unuseful.

> As you wish.  But, in my opinion, this is a slippery
> slope which ends up in trouble eventually.  One of
> the worse potential problems with this tactic, which
> 've seen before, is that it leads to developers
> delaying or avoiding future ICS (or any thrid-party
> library) improvements, revisions, and sometimes
> important bug-fixes because of the overwhelming
> thought of having to track down all possible
> modifications and figure out how to merge them back
> into the code-base; which ones have been obsoleted by
> the update; and which new ones will be needed.
Thank you, I'll consider it!

--
Regards, 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] I wan't to stop the server from listening then start it

2008-10-31 Thread Anton Sviridov
> IMO, this will even be worse. When you'll use the next update, you'll be 
> introuble whatever change you've done in the source.

No troubles, I add my signature in comments to track what I've changed in 
source, and use WinDiff to inject your improvements.

> The correct way doing such behaviour change is to derive your own class 
> fromTWSocket and override AssignDefaultValue procedure. This is a nice 
> exampleabout what OOP is for.

It could be nice when using only non-visual TWSocket. Otherwise we receive 
additional troubles: derive our own component; install it into IDE. And what if 
we have to use other class, for example, ftp client? What we should do in this 
case? Derive our new ftp client class, redeclare Controlsocket and Datasocket 
properties? No, thanks... I'd better put several // in the code and will be 
happy ))

--
Regards, 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] I wan't to stop the server from listening then start it

2008-10-30 Thread Anton Sviridov
Port, protocol, proxy fields of Socket are cleared on Close. Really embarassing 
and hard-to-discover feature.
For my projects, I've commented some corresponding lines in ISC source

--
Regards, 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] TWSocket: ResolveHost and Socks5

2008-10-08 Thread Anton Sviridov
I see that remote host is always resolved before a call to Connect. Though, 
Socks5 makes it possible not to care about it, and it is realized here:
 Buf[0] := $05;{ Socks version }
 Buf[1] := $01;{ Connect command }
 Buf[2] := $00;{ Reserved, must be $00 }
 Buf[3] := $03;{ Address type is domain name }
 Buf[4] := Length(FAddrStr);
so what's the goal of host resolving when socks5 is used?

--
regards, 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] TWSocket. Receiving data very quickly hangs app

2008-09-03 Thread Anton Sviridov
...and, sorry for flooding, thank you for an example of custom message loop, it 
is very useful!

--
Regards, 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] TWSocket. Receiving data very quickly hangs app

2008-09-03 Thread Anton Sviridov
> Only one message loop is required per thread.

Thanks, Ando! This is not a sort of obvious things, I even haven''t an idea of 
it.
I wrote

   while not Terminated do
   clients[0].MessageLoop;

and launched 10 clients through localhost - everything is OK, application 
doesn''t even slow down. Though cpu usage is near 85%, but it works!

--
Regards, 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] TWSocket. Receiving data very quickly hangs app

2008-09-03 Thread Anton Sviridov
So, if I want to implement several sockets in a single threads, how do I 
perform a message loops on each of them?

This

procedure TMyThread.Execute;
begin
WSocket1  := TWSocket.Create(nil);
try
 Assign event handlers and properties..
  WSocket1.Connect;
 // Start the message loop, post WM_QUIT message latert to break 
the loop.
  WSocket1.MessageLoop;
   finally
  WSocket1.Free;
  end;
end;

works only if we create one thread for each socket. I tried this:

procedure TSocketThread.Execute;
var i: integer;
begin
  ..create and run .Connect...

   while not Terminated do
 for I := 0 to length(clients) - 1 do
 begin
   if clients[i]<>nil then clients[i].MessagePump;
 end;

end;

is it right?

--
Regards, 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] TWSocket. Receiving data very quickly hangs app

2008-09-03 Thread Anton Sviridov
Arno Garrels wrote:
> On very fast transfers it happens that certain messages are delayed.
> To keep your GUI responsive you can run ICS in a single worker thread.

Yes, I'm starting to understand it )). I'll try to implement one thread.

> Localhost connections are very, very fast, that's no real test case.

This is the easiest way of testing application for performance when 10-20 
simultaneous connections are established.

--
Regards, 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] TWSocket. Receiving data very quickly hangs app

2008-09-02 Thread Anton Sviridov
If the application receives data very quickly (on a localhost, data is read 
from file), DataAvailable cycle "hangs" application preventing all other 
actions. I''ve tryed to set wsoNoReceiveLoop, but that didn''t change 
something. When I set a *small* delay in my test server app (20 msec), all 
works fine.
What should I do? I''m going to use dozens of client connections at once, and 
what it would like if there are problems even with single client?

--
Regards, 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] FTPCli: Lose Socks settings in DataSocket on Close

2008-08-25 Thread Anton Sviridov
> Yes they do, since they only want to send it once when downloading 1,000
> files or directories, not 1,000 times.

I suppose it''s better to waste 0.5 sec and 10 bytes of traffic on setting type 
each time before download than constantly keep in mind, what type is set now 
and whether we have to change it or not. Of course, it''s just a my opinion.

Another issue I noticed is a strange behavior with LocalStream. It supposed to 
be an external object, created outside FTPCli. So who has given the component a 
right to Destroy it in DestroyLocalStream?
I''ll describe step by step.

1) Create SomeStream in the main program
2) Create FTPCli, all stuff
3) Assign FTPCli.LocalStream to SomeStream
4) Perform dir listing, parsing received info and so on

-- until that FStreamFlag prevents LocalStream from destroying --

5) Start downloading files, (!!!) Set LocalFileName. FStreamFlag changes to 
False, but LocalStream is still assigned!
6) GetAsync destroys LocalStream, and, hence, our SomeStream.
7) So we have SomeStream which points to nothing, and we are one step away from 
Access violation

Maybe I misunderstood the logic of the process, then please tell me which way 
would be right.
But as I see, this is a kind of logical bug. Looks like the best solution would 
be setting LocalStream to nil in SetLocalFileName

--
Best Regards, 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] FTPCli: Lose Socks settings in DataSocket on Close

2008-08-21 Thread Anton Sviridov
Thanks for answer, Angus!
If you need socks proxy for testing, you could use Squid or 3proxy 
(http://3proxy.ru/?l=EN)

I am improving the component for my purposes now and could send to this mail 
list my modifications.

Another thing is sending TYPE before receiving dir list or file. I think it's 
not something that user want to implement manually.

procedure TCustomFtpCli.DirAsync;
begin
   HighLevelAsync(ftpDirAsync, [{}ftpFctTypeSet,{} ftpFctPort, ftpFctDir]);
end;

procedure TCustomFtpCli.GetAsync;
begin
 HighLevelAsync(ftpGetAsync, [{}ftpFctTypeSet{}, ftpFctPort, ftpFctGet]);
end;

All we have to do after that is to set Binary property before call to this 
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

[twsocket] FTPCli: Lose Socks settings in DataSocket on Close

2008-08-20 Thread Anton Sviridov
Hi all!
Today I faced with strange behavior in my simple FTP program: if I perform dir 
listing adn then try to get a file, RETR is sent and then 15 sec timeout and 
error 550. When I download file without dir listing, all is OK.
Digged to the code and wasted some time, I understood that after Socket.Close 
all its properties are returned to defaults, also including Socks server 
properties! So when I connect DataSocket 2nd time it doesn''t have any idea 
that it must use Socks. Am I supposed to reconnect to server for each 
operation, or to set Socks properties again and again for every file download?
As I see, solution is to reassign fields in TCustomFtpCli.DataSocketGetInit, 
but imho there is more logical not to clear them on closing.
Hope you''ll fix that.

--
Best regards, 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