Re: [twsocket] SmtpClient problem on disconnect

2006-11-18 Thread David A. G.
Thanks for all, I understand. Today I have tryed with a simple TCP client 
emulating the SMTP protocol manually, and ALL works good, the server is 
closing the connection. But again using the SmtpCli.pas component the 
connection is not closed or OnRequestDone is not fired (this only happens 
when using EHLO with AUTH LOGIN).

Well I will keep trying...

thanks,
David


- Original Message - 
From: Francois Piette [EMAIL PROTECTED]
To: ICS support mailing twsocket@elists.org
Sent: Friday, November 17, 2006 11:00 AM
Subject: Re: [twsocket] SmtpClient problem on disconnect


 In my opinion, the servers are not compliant with the standard. Indtead of
 tweaking the component, either simply colse the connection yourself or
 implement a timeout and close it later if the server don't do it quickly
 enough for you.

 Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html
 --
 [EMAIL PROTECTED]
 Author of ICS (Internet Component Suite, freeware)
 Author of MidWare (Multi-tier framework, freeware)
 http://www.overbyte.be

 - Original Message - 
 From: David A. G. [EMAIL PROTECTED]
 To: TWsocket twsocket@elists.org
 Sent: Friday, November 17, 2006 12:05 AM
 Subject: [twsocket] SmtpClient problem on disconnect


 Hello all:

 I'm having problems SmtpCli where OnRequestDone function is not fired
 after
 sending QUIT command because the SMTP server is not closing the
 connection!!. It occurs only when using EHLO command and AUTH LOGIN
 authentication. I have tryed with 2 servers with same results (big linux
 servers).

 To solve that, I have changed SmtpProt.pas:

 FROM:

 procedure TCustomSmtpClient.NextExecAsync;
 ...
 ...
 if Assigned(FDoneAsync) then
 FDoneAsync
 else if (FRequestType  smtpQuit) or (FConnected = FALSE) then
 TriggerRequestDone(FRequestResult)
 else begin
 { We have to wait until remote host close connection before  }
 { calling TriggerRequestDone. See WSocketSessionClosed. }
 end;
 end;


 TO:

 procedure TCustomSmtpClient.NextExecAsync;
 ...
 ...
 if Assigned(FDoneAsync) then
 FDoneAsync
 else
 TriggerRequestDone(FRequestResult)
 end;
 end;
 ...then in the OnRequestDone I can close connection (if necessary) by
 calling CloseDelayed.


 any idea??

 thanks in advance,
 David
 -- 
 To unsubscribe or change your settings for TWSocket mailing list
 please goto http://www.elists.org/mailman/listinfo/twsocket
 Visit our website at http://www.overbyte.be

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


Re: [twsocket] Pulling my hair out trying to receive a record

2006-11-18 Thread Francois PIETTE
  Ptr := PByte(X);
  while iSize  0 do begin
iSent := WSocket_AsClient.Send(Ptr, iSize);
if iSent  0 then begin
  Inc(Ptr, iSent);
  Dec(iSize, iSent);
  Continue;
end;

Your record will be sent in one call to Send(). No need to do a loop !
Also no need to use an intermediate pointer.
Just do:
WSocket_AsClient.Send(X, iSize);

if iSent = 0 then begin
  ClientSocket.Close;
  raise Exception.Create('Connection closed gracefully');
end;

Just throw that code away ! It is not needed. In your code iSent is the 
number of bytes sent. It will always succeed because data is put into a send 
buffer for sending. You could get an exception if you run out of memory or 
if the socket is not connected.

iErrorCode := WSAGetLastError;
if iErrorCode  WSAEWOULDBLOCK then
  raise Exception.CreateFmt('Socket Error: %d', [iErrorCode]);

You have to throw away this code. You'll get exceptions (to be handled with 
try/except) or you get error codes in the events arguments.

 --and in my real app the SessionAvailable() handler is fired, but the
 SessionConnected() does not, nor does OnDataAvailable().

I don't understand what you real app is. It is your server application ? 
Is it built using TWSocketServer ?
Don't use TWSocket for listening, use TWSocketServer which do all the 
housekeeping needed to handle simultaneous clients.

--
Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html
--
[EMAIL PROTECTED]
http://www.overbyte.be



- Original Message - 
From: Clay Shannon [EMAIL PROTECTED]
To: 'ICS support mailing' twsocket@elists.org
Sent: Friday, November 17, 2006 9:49 PM
Subject: [twsocket] Pulling my hair out trying to receive a record


I am trying to test sending records from a utility to my app, which should
 receive and process the records.



 I am able to send the record from my test utility with this code:



 procedure TForm10.btnSendMsgAsRecordClick(Sender: TObject);

 begin

  InitializeWSocketProperties;

  WSocket_AsClient.Connect;

 end;



 procedure TForm10.InitializeWSocketProperties;

 begin

  WSocket_AsClient.Addr := '10.172.2.93'; { TODO : After testing, read 
 these
 vals from an .INI file }

  WSocket_AsClient.Port := '1234';

 end;



 {== After connecting, this event is called ==}

 procedure TForm10.WSocket_AsClientSessionConnected(Sender: TObject; 
 ErrCode:
 Word);

 begin

  if ErrCode  0 then begin

ShowMessage(Format('Error in OnSessionConnected() event: %d',
 [ErrCode]));

Exit;

  end;

  SendTheCurrentRecord;

 end;



 procedure TForm10.SendTheCurrentRecord;

 begin

  if cmbxMsgType.Items[cmbxMsgType.ItemIndex] = 'ACTIVATE_BOF_SORT' then

SendActiv8BOFSortRecord //This is the one I'm testing

. . .



 procedure TForm10.SendActiv8BOFSortRecord;

 var

  X: PActivateBOFSort;

  Ptr: PByte;

  iSent, iSize, iErrorCode: Integer;

 begin

  iSize := SizeOf(TActivateBOFSort);

  X := AllocMem(iSize);

  X^.OpCode := ACTIVATE_BOF_SORT;

  X^.Carrier := StrToIntDef(edt1.Text, 0);

  StrLCopy(X^.BOFSortLabel, PChar(edt2.Text), BOF_SORT_LABEL_LENGTH);

  X^.WorkstationOffset := StrToIntDef(edt3.Text, 0);

  X^.RecordTerminator := '~';

  Ptr := PByte(X);

  while iSize  0 do begin

iSent := WSocket_AsClient.Send(Ptr, iSize);

if iSent  0 then begin

  Inc(Ptr, iSent);

  Dec(iSize, iSent);

  Continue;

end;

if iSent = 0 then begin

  ClientSocket.Close;

  raise Exception.Create('Connection closed gracefully');

end;

iErrorCode := WSAGetLastError;

if iErrorCode  WSAEWOULDBLOCK then

  raise Exception.CreateFmt('Socket Error: %d', [iErrorCode]);

  end;



 --and in my real app the SessionAvailable() handler is fired, but the
 SessionConnected() does not, nor does OnDataAvailable().



 What am I missing here? What necessary step am I leaving out?



 I have this code (adapted from one of the ICS demo apps) in the
 OnSessionAvailable() handler of my receiving app:



 procedure TfClientMain.WSocket_AsServerSessionAvailable(Sender: TObject;
 ErrCode: Word);

 var

  NewHSocket : TSocket;

  Peer   : String;

 begin

  { We need to accept the client connection }

  NewHSocket := WSocket_AsServer.Accept;

  { And then associate this connection with our client socket }

  WSocket_AsClient.Dup(NewHSocket);

 end;



 ...and this code in OnSessionConnected(), but it doesn't get reached (also
 taken from some code gleaned from the mailing list):



 procedureTfClientMain.WSocket_AsServerSessionConnected(Sender: TObject;
 ErrCode: Word);

 begin

  ICS_RdPtr := 0;

  ICS_WrPtr := 0;

  if ICS_BufferSize = 0 then begin

ICS_BufferSize := ICS_BUFFER_SIZE;

ReAllocMem(ICS_Buffer, ICS_BufferSize);

  end;

 end;



 ...and this preliminary code in OnDataAvailable(), which also is not 
 getting
 reached:



 procedure TfClientMain.WSocket_AsServerDataAvailable(Sender: TObject;
 ErrCode: Word);

 var

  sIncomingDataAsString: String;

 begin

  if 

[twsocket] Flow control

2006-11-18 Thread Angus Robertson - Magenta Systems Ltd
If I'm trying to send random data at a speed faster than a TCP socket 
can support, what errors should I expect from TWSocket.Send?  This might 
be a slow connection, or a remote that can not process the stream fast 
enough.  

I can not see any error handling in the send buffering code to reject 
sends when prior data has not been sent and the buffer is full, so I 
added:

  if len  (BufSize - BufferedByteCount) then

to try and check it.  I tried to test this by exiting 
SocketDataAvailable without receiving any data, but the application 
simply went into 100% CPU as the event was continually called without 
processing any other messages.  

This 100% symptom is something I've seen several times recently in one 
of my major applications, when another application on the PC started 
using a lot of CPU for a short period, then mine started using 100% 
until crashed with Task Manager.

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


[twsocket] Multi-Threaded THttpServer?

2006-11-18 Thread Cosmin Prund
Hello!

Here's me again, trying to do strange things. I'm working on a HelpDesk 
application that should include a Chat function, amongst other things. I 
want to do it all using HTTP only (that is, no direct connection, 
everything needs to be pure HTTP). I really want this HTTP-only thing 
because I want my application to work in places where my clients only 
have access to the Internet using an HTTP Proxy!

The chat application has 2 basic components: send your text, receive 
text sent by the other party. The send your text is really easy, but 
the receive text sent by the other party part is a bit more difficult, 
because I can't keep an open connection between client and server, I 
need the client to pool for text sent from the server! That is, the 
client will GET a document of the following format:
http://myserver.server.ro/getchat?conversation=12346seq=1
The server should return any available text for the given conversation 
or an NOP if no text is available. But here's a trick: If there's no 
text available for the connection I would like to delay returning an NOP 
until there IS some text available, or until a 10 seconds delay elapses. 
This would stop the client from going into a bandwidth-consuming busy-loop.

Unfortunately THttpServer doesn't include a MultiThreaded checkbox 
like TSocketServer does, and I'm not sure what I should do to Sleep() 
without actually freezing the server in the process! I might try 
subclassing THttpServer and setting FWSocketServer.MultiThreaded = True 
in CreateSocket but I know too little about the internals of THttpServer 
and ICS in general to understand the consequences of doing this.

Any help on the matter is welcomed, thanks.

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


Re: [twsocket] HttpCli ContentRangeBegin

2006-11-18 Thread Francois PIETTE
 Conclusion: I think data corruption might be a problem in some cases.
 Notice how all Linux distributions include MD5 hashes for all downloads,
 so they can be checked on the receiving end?

This is not to detect data corrumption because of data transmission but to 
detect man in the middle attack. MD5 checksum allow the user to check if 
the data file he downloaded is the same as the data file the developper 
dropped on the server and was not replaced either on the server or by 
someone intercepting the communication.

In think in the context you mention, MD5 is used for security, no for data 
integrity.

 I decided to implement MD5-based file checking for my downloads
 (my application only downloads
 stuff from my own site, so I've got everything under my control). I've
 done this because I know I've got quite a few clients on very bad
 dial-up lines. If I didn't have those clients I would have done no
 checking at all.

ICS include MD5 support (as well as MD4 and SHA1). The latest beta also 
support FTP extensions for MD5 checksumming.

--
Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html
--
[EMAIL PROTECTED]
http://www.overbyte.be


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


Re: [twsocket] SmtpClient problem on disconnect

2006-11-18 Thread Francois PIETTE
 Thanks for all, I understand. Today I have tryed with a simple TCP client
 emulating the SMTP protocol manually, and ALL works good, the server is
 closing the connection. But again using the SmtpCli.pas component the
 connection is not closed or OnRequestDone is not fired (this only happens
 when using EHLO with AUTH LOGIN).

 Well I will keep trying...

Use a sniffer such as Ethereal (link available form the links page at 
http://www.overbyte.be) to see exactly what happend. You'll see if the 
server close the connection and SMTP component miss this close. You'll also 
be able to reproduce the exact same dialog that the SMTP component does and 
see if it result in the same effect at server side. Sometimes bugs are very 
subtule and only a space somewhere can change everything. It may also be 
some race condition at server side. The component is working very fast 
compared to your manual test.

--
Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html
--
[EMAIL PROTECTED]
http://www.overbyte.be


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


Re: [twsocket] Shutdown(How: Integer)

2006-11-18 Thread Francois PIETTE
 When do I need, or would I want, to call Shutdown(), and what are the
 ramifications of the different parameters that one can pass it.

You use Shutdown() to initiate a gracefull close of a TCP session. 
Shutdown() send the signal to the remote side to close the connection. The 
remote side see it as a connection gracefully closed by peer. It should the 
close his end of the connection. The peer which initially called SHutdown() 
will then receive the connection close signal.

 I see Shutdown(2) in one of the demo apps, but don't know what 2
 represents.

  { Manifest constants for Shutdown }
  SD_RECEIVE= 0;
  SD_SEND   = 1;
  SD_BOTH   = 2;


--
Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html
--
[EMAIL PROTECTED]
http://www.overbyte.be


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


Re: [twsocket] Need example code for identifying a record beforeprocessing

2006-11-18 Thread Francois PIETTE
 All of the records have as their first member an Integer named OpCode 
 which
 identifies itself as to which type of record it is, such as:
  PInductionComplete = ^TInductionComplete;
  TInductionComplete = packed record
OpCode: Integer;
Sort: Integer;
CarrierCount: Integer;
GreenLightMilliseconds: Integer;
OccupiedTrays: Integer;
RecordTerminator: Char; //This is the #126, or tilde/~ char
  end;

I will be receiving a variety of structs/records, all of different sizes 
and
 makeups.

 How can I (in the OnDataAvailable() handler, I assume), determine/identify
 which record has just come in, so that I can process it accordingly?

Just check the OpCode record member which tells what record type you have.
If you have received the record, or part of the record (be sure to have 
received at least 4 bytes since your OpCode is an integer) into a buffer, 
cats the buffer address to a pointer to an integer and grab your OpCode. 
Somethinhg like that:

MyOpCode := PInteger(@Buffer)^;


 OnDataAvailable() should only fire once for each record, because I am 
 having
 the sender add a #126 (~) as the last byte of each record, and using
 LineMode with LineEnd = #126.

WARNING: Since your record contains binary data, it could contains a #126 as 
part of the data. So the line mode will not work as you expect !

You have to make sure your record doesn't contain your termination 
character. You can use an escape mechanism for that purpose. You scan all 
the bytes in your data for the delimiter and replace it by another byte. 
Since this byte may as well be in the data, you must also substitute it. 
This result as having your delimiter (#126) replaced by TWO bytes: an escape 
character (anything you like but not #126. Let's say it is #127) and #1 (for 
example); and your escape character is replace by TWO of them. When you 
received data, you do the reverse processing: replace #127#1 by #126 and 
#127#127 by a single #127.

Alternatively, you may send your data in text form instead of binary form. 
It takes more space but you have no problem with line end terminator (The 
default CRLF is perfect) and you avoid problem with binary representation of 
data which DIFFER from one processor to another processor.

--
Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html
--
[EMAIL PROTECTED]
http://www.overbyte.be


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


Re: [twsocket] Multi-Threaded THttpServer?

2006-11-18 Thread Dan
You could either:
(1) Not reply to the client until after 10 seconds (using a TTimer?).  You
don't have to sleep.  I'm sure the HTTP server has some kind of delayed
reply mechanism.  You can put the client in a 'waiting' list and only send
the reply after your timeout.

(2) Have the client only retry after 10 seconds.  There is a header you can
send to get the client to refresh to a new URL after so many seconds.  Many
sites use it for redirects...they redirect after 5 seconds for example.

Dan

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Cosmin Prund
Sent: 18 November 2006 12:55
To: ICS support mailing
Subject: [twsocket] Multi-Threaded THttpServer?

Hello!

Here's me again, trying to do strange things. I'm working on a HelpDesk 
application that should include a Chat function, amongst other things. I 
want to do it all using HTTP only (that is, no direct connection, 
everything needs to be pure HTTP). I really want this HTTP-only thing 
because I want my application to work in places where my clients only 
have access to the Internet using an HTTP Proxy!

The chat application has 2 basic components: send your text, receive 
text sent by the other party. The send your text is really easy, but 
the receive text sent by the other party part is a bit more difficult, 
because I can't keep an open connection between client and server, I 
need the client to pool for text sent from the server! That is, the 
client will GET a document of the following format:
http://myserver.server.ro/getchat?conversation=12346seq=1
The server should return any available text for the given conversation 
or an NOP if no text is available. But here's a trick: If there's no 
text available for the connection I would like to delay returning an NOP 
until there IS some text available, or until a 10 seconds delay elapses. 
This would stop the client from going into a bandwidth-consuming busy-loop.

Unfortunately THttpServer doesn't include a MultiThreaded checkbox 
like TSocketServer does, and I'm not sure what I should do to Sleep() 
without actually freezing the server in the process! I might try 
subclassing THttpServer and setting FWSocketServer.MultiThreaded = True 
in CreateSocket but I know too little about the internals of THttpServer 
and ICS in general to understand the consequences of doing this.

Any help on the matter is welcomed, thanks.

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


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


Re: [twsocket] Telnet problems

2006-11-18 Thread Markus Humm
 Francois replied:
 
 I think TTnScript is the way to go. You can dynamically add/remove events
 according to which screen you detect. If you don't use TTnScript, has a
 look at his source code to understand how to get hand on the input stream to
 chack for data.
 
 I also uploaded a modified version of the components. It is a proposal of
 changes by John Porteous. It will probably appear shortly in the
 distribution. You may try it:
 http://www.overbyte.be/arch/dump/EmulVTJohnPorteous.zip
 
 

Hello,

I already looked at TnScript 2-3 minutes, but I think this only works if
the Telnet session is designed like this:

Step 1 - Step 2 - Step 3... so each step is a screen completely
different from each other.

My session will more look like this:

Step 1 (Screen 1) - Step 2 (Screen 2) - Step 3 (Screen 1 again) etc. so
the same screen will come again and again.

Do you have a short example of this (for my special case)?
And I can't guarantee that the last line is always the same for these
screens, because the vendor of the device to be configured could enhance
the configuration...
Or some explanaitions on OnDataAvailable, OnLocalEcho, the properties
LocalEcho and Backlog? And in my app. I see that the telnet session is
messed up, means part of the screen which should be displayed top is
delayed and thus displayed at the bottom rather. I think it comes from
sending the next command to fast (when not yet all data has been
received from the old one) so it messes up. One idea of mine is to send
the first command, wait for the first OnDataAvailable and then do a sort
of busy wait or similar until a certain period is over so that delayed
OnDataAvailables for the same screen can pass and then send the next
command. Is this feasible? Otherwise I'd use a TnCNX if the TnScript
based method doesn't work.

Greetings

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


Re: [twsocket] Multi-Threaded THttpServer?

2006-11-18 Thread Francois PIETTE
You defenitely doin't need multithread to throttle a connexion. See how it 
is done in the HTTP client component where you have a Bandwidth limitation 
feature.

 I'm working on a HelpDesk application that should include a Chat function,
 amongst other things. I want to do it all using HTTP only

You could be interested by my IMD messaging system (Real time chat like 
MSN). It only uses HTTP. See my website.

--
Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html
--
[EMAIL PROTECTED]
http://www.overbyte.be


- Original Message - 
From: Cosmin Prund [EMAIL PROTECTED]
To: ICS support mailing twsocket@elists.org
Sent: Saturday, November 18, 2006 1:55 PM
Subject: [twsocket] Multi-Threaded THttpServer?


 Hello!

 Here's me again, trying to do strange things. I'm working on a HelpDesk
 application that should include a Chat function, amongst other things. I
 want to do it all using HTTP only (that is, no direct connection,
 everything needs to be pure HTTP). I really want this HTTP-only thing
 because I want my application to work in places where my clients only
 have access to the Internet using an HTTP Proxy!

 The chat application has 2 basic components: send your text, receive
 text sent by the other party. The send your text is really easy, but
 the receive text sent by the other party part is a bit more difficult,
 because I can't keep an open connection between client and server, I
 need the client to pool for text sent from the server! That is, the
 client will GET a document of the following format:
 http://myserver.server.ro/getchat?conversation=12346seq=1
 The server should return any available text for the given conversation
 or an NOP if no text is available. But here's a trick: If there's no
 text available for the connection I would like to delay returning an NOP
 until there IS some text available, or until a 10 seconds delay elapses.
 This would stop the client from going into a bandwidth-consuming 
 busy-loop.

 Unfortunately THttpServer doesn't include a MultiThreaded checkbox
 like TSocketServer does, and I'm not sure what I should do to Sleep()
 without actually freezing the server in the process! I might try
 subclassing THttpServer and setting FWSocketServer.MultiThreaded = True
 in CreateSocket but I know too little about the internals of THttpServer
 and ICS in general to understand the consequences of doing this.

 Any help on the matter is welcomed, thanks.

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

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


Re: [twsocket] Flow control

2006-11-18 Thread Francois PIETTE
 If I'm trying to send random data at a speed faster than a TCP socket
 can support,

I don't understand what you want. Obviously you can't make a TCP session 
running fatser than a TCP session ! You can make it run slower but not 
faster !

Or maybe you want to use UDP which is faster than TCP but lacks the error 
detection and correction TCP has.


--
Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html
--
[EMAIL PROTECTED]
http://www.overbyte.be


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


Re: [twsocket] Multi-Threaded THttpServer?

2006-11-18 Thread Francois PIETTE
 (1) Not reply to the client until after 10 seconds (using a TTimer?).  You
 don't have to sleep.  I'm sure the HTTP server has some kind of delayed
 reply mechanism.  

Yes, you can reply later. Use hgSendMySelf.


--
Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html
--
[EMAIL PROTECTED]
http://www.overbyte.be


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


Re: [twsocket] Telnet problems

2006-11-18 Thread Francois PIETTE
 I already looked at TnScript 2-3 minutes, but I think this only works if
 the Telnet session is designed like this:

 Step 1 - Step 2 - Step 3... so each step is a screen completely
 different from each other.

TTnScript associate events to strings detected in the data flow no matter 
how it is organized in screens. You can add/remove events dynamically if 
you have complex things to do.

 My session will more look like this:

 Step 1 (Screen 1) - Step 2 (Screen 2) - Step 3 (Screen 1 again) etc. so
 the same screen will come again and again.

 And I can't guarantee that the last line is always the same for these
 screens, because the vendor of the device to be configured could enhance
 the configuration...

There is no guarantee. It is only dependent on the way the device vendor 
organized his program.

 Do you have a short example of this (for my special case)?

I have no example for any case :-(
I wrote that code to automate a specific application I had to write. And as 
usual I've put that code in a reusable component. The only doc I have is 
what you can see in the comments in the source file.

 Or some explanaitions on OnDataAvailable,

Data has been received.

 OnLocalEcho, the properties LocalEcho

That is telnet protocol options negociation. Using telnet (as with an old 
RS232 terminal), when a user type on the keyboard, the character is either 
immediately shown on screen (local echo on) and sent to the remote host, or 
(local echo off) only sent to the remote host which will echo it back to the 
user screen.

 and Backlog?

The component handle terminal emulation with the screen higher than actual 
screen. For example, the host think it has a 80x25 screen while the 
component keep characters which have scrolled out of the screen.


--
Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html
--
[EMAIL PROTECTED]
http://www.overbyte.be


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


Re: [twsocket] Multi-Threaded THttpServer?

2006-11-18 Thread Cosmin Prund
Dan wrote:
 You could either:
 (1) Not reply to the client until after 10 seconds (using a TTimer?).  You
 don't have to sleep.  I'm sure the HTTP server has some kind of delayed
 reply mechanism.  You can put the client in a 'waiting' list and only send
 the reply after your timeout.
   
That would be plain simply perfect for what i need but how do I do that? 
For the moment I only know how to use the OnGetDocument to generate the 
response and it doesn't provide any room for delaying it's processing! 
At what point in time, or where from can I put a request on hold so it 
doesn't get processed normally? Please note I need to have at least part 
of the processing go normally, so I actually know it's a valid HTTP 
request and I know what document the user is requesting etc.
 (2) Have the client only retry after 10 seconds.  There is a header you can
 send to get the client to refresh to a new URL after so many seconds.  Many
 sites use it for redirects...they redirect after 5 seconds for example.

   
That would be easy to implement but would not solve the problem (at 
least not in an acceptable way). In this way the client would receive 
messages in batches every 10 seconds (or whatever the retry time is). If 
I have the server do the waiting the messages will flow much faster.
 Dan

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
 Behalf Of Cosmin Prund
 Sent: 18 November 2006 12:55
 To: ICS support mailing
 Subject: [twsocket] Multi-Threaded THttpServer?

 Hello!

 Here's me again, trying to do strange things. I'm working on a HelpDesk 
 application that should include a Chat function, amongst other things. I 
 want to do it all using HTTP only (that is, no direct connection, 
 everything needs to be pure HTTP). I really want this HTTP-only thing 
 because I want my application to work in places where my clients only 
 have access to the Internet using an HTTP Proxy!

 The chat application has 2 basic components: send your text, receive 
 text sent by the other party. The send your text is really easy, but 
 the receive text sent by the other party part is a bit more difficult, 
 because I can't keep an open connection between client and server, I 
 need the client to pool for text sent from the server! That is, the 
 client will GET a document of the following format:
 http://myserver.server.ro/getchat?conversation=12346seq=1
 The server should return any available text for the given conversation 
 or an NOP if no text is available. But here's a trick: If there's no 
 text available for the connection I would like to delay returning an NOP 
 until there IS some text available, or until a 10 seconds delay elapses. 
 This would stop the client from going into a bandwidth-consuming busy-loop.

 Unfortunately THttpServer doesn't include a MultiThreaded checkbox 
 like TSocketServer does, and I'm not sure what I should do to Sleep() 
 without actually freezing the server in the process! I might try 
 subclassing THttpServer and setting FWSocketServer.MultiThreaded = True 
 in CreateSocket but I know too little about the internals of THttpServer 
 and ICS in general to understand the consequences of doing this.

 Any help on the matter is welcomed, thanks.

 --
 Cosmin Prund
   

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


Re: [twsocket] Multi-Threaded THttpServer?

2006-11-18 Thread Arno Garrels
Cosmin Prund wrote:
 The server should return any available text for the given conversation
 or an NOP if no text is available. But here's a trick: If there's no
 text available for the connection I would like to delay returning an
 NOP until there IS some text available, or until a 10 seconds delay
 elapses. This would stop the client from going into a bandwidth-
 consuming busy-loop. 

You realy do not need multiple threads to achieve that, send the 
response when text is available or close the connection after 10 seconds.
Multi-threading should be used only when the client needs to carry out
lengthy jobs like executing a SQL query or calculating a MD5 checksum
on a big, uploaded file.

---
Arno Garrels [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html


 
 Unfortunately THttpServer doesn't include a MultiThreaded checkbox
 like TSocketServer does, and I'm not sure what I should do to Sleep()
 without actually freezing the server in the process! I might try
 subclassing THttpServer and setting FWSocketServer.MultiThreaded =
 True in CreateSocket but I know too little about the internals of
 THttpServer and ICS in general to understand the consequences of
 doing this. 
 
 Any help on the matter is welcomed, thanks.
 
 --
 Cosmin Prund
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Multi-Threaded THttpServer?

2006-11-18 Thread Cosmin Prund
Francois PIETTE wrote:
 You defenitely doin't need multithread to throttle a connexion. See how it 
 is done in the HTTP client component where you have a Bandwidth limitation 
 feature.
   
I'm not interested in throttling a connection. I don't have an set 
amount of data and want to send it a slower rate. I just want to delay 
answering a request for a while, hoping I'll have an better answer a few 
seconds later. This is a bit of pseudo code for what I think I'll be 
able to do in OnGetDocumnet if OnGetDocument would be a blocking thread. 
I'm not saying this is the only way to do it, but this is what I want to do:

function GetNextMessage(Connection):string;
var MaxDelay:TDateTime;
begin
  MaxDelay := Now + EncodeTime(0, 0, 10, 0);
  while (not Connection.MessagesAvailable) and (Now  MaxDelay) do
Sleep(100);
  if Connection.MessagesAvailable then
Result := Connection.ConcatenatedMessages
  else
Result := 'NOP';
end;


Well... since starting writing this message I received an other 
Francoise PIETTE answer to my question on the mailing list (the 
hgWillSendMySelf answer) and that provides a much better solution to my 
problem! I can now imagine better ways of exploiting the HTTP protocol 
in order to get my message across, without threads and blocking 
communications.

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


Re: [twsocket] Multi-Threaded THttpServer?

2006-11-18 Thread Cosmin Prund
Francois PIETTE wrote:
 (1) Not reply to the client until after 10 seconds (using a TTimer?).  You
 don't have to sleep.  I'm sure the HTTP server has some kind of delayed
 reply mechanism.  
 

 Yes, you can reply later. Use hgSendMySelf
Does it work like this?

In my OnGetDocument I set Flags to hgWillSendMySelf and then use the 
client component's send method do send() the data, then use it's 
Shutdown() method to gracefully close the connection and let the other 
side know I've finished sending? Or is there something more to this, 
like taking into account Keep Alive connections?

I can figure it out myself from here, thanks for the tip!

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


Re: [twsocket] Flow control

2006-11-18 Thread Angus Robertson - Magenta Systems Ltd
 I don't understand what you want. Obviously you can't make a TCP 
 session running fatser than a TCP session ! 

But I can supply data faster than the session can support.  The data 
might be coming from another application and I'm sending it over a slow 
modem, so there must be flow control somewhere when the TCP buffers 
overflow.  But I can not find it.  

Send does not currently appear to check data has previously been sent 
and there is space in the buffer.  

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


Re: [twsocket] SmtpClient problem on disconnect

2006-11-18 Thread David A. G.
I have post a demo in my webserver. If any one want to try it to see the 
problem and test it with your own SMTP, please download it from:

http://www.mcrenox.com.ar/smtptest.zip

Remember use SMTP servers with AUTH if possible.

thanks
David


- Original Message - 
From: Francois PIETTE [EMAIL PROTECTED]
To: ICS support mailing twsocket@elists.org
Sent: Saturday, November 18, 2006 10:11 AM
Subject: Re: [twsocket] SmtpClient problem on disconnect


 Thanks for all, I understand. Today I have tryed with a simple TCP client
 emulating the SMTP protocol manually, and ALL works good, the server is
 closing the connection. But again using the SmtpCli.pas component the
 connection is not closed or OnRequestDone is not fired (this only happens
 when using EHLO with AUTH LOGIN).

 Well I will keep trying...

 Use a sniffer such as Ethereal (link available form the links page at
 http://www.overbyte.be) to see exactly what happend. You'll see if the
 server close the connection and SMTP component miss this close. You'll 
 also
 be able to reproduce the exact same dialog that the SMTP component does 
 and
 see if it result in the same effect at server side. Sometimes bugs are 
 very
 subtule and only a space somewhere can change everything. It may also be
 some race condition at server side. The component is working very fast
 compared to your manual test.

 --
 Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html
 --
 [EMAIL PROTECTED]
 http://www.overbyte.be


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

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