Re: [twsocket] Flow control

2006-11-21 Thread Francois Piette
There is nothing to understand in the buffering. The buffer is automatic and
only limited by available virtual memory. You get an exception when you run
out of memory, just like you have - for example - when you run out of memory
trying to add strings to a TStringList or anything else. That is just plain
basic Delphi programming.

Your program has access to BufferedByteCount at anytime to know what the
size of the buffer is. I don't see any advantage to have the component check
the value against some limit and make Send fail, trigger an event or an
exception. Just check the property before calling Send !

--
[EMAIL PROTECTED]
http://www.overbyte.be

- Original Message - 
From: Angus Robertson - Magenta Systems Ltd [EMAIL PROTECTED]
To: twsocket@elists.org
Sent: Monday, November 20, 2006 2:02 AM
Subject: Re: [twsocket] Flow control


  Have you notice BufferedByteCount property ?

 Yes, I mentioned in my first message, but since it's undocumented (not
 mentioned in the Wiki, FAQ or Help) it took me a while to understand how
 the wsocket buffering works.

 But in this case, TWSocket is poorly designed and network issues can
 allow an application to crash out of memory without any earlier errors.
 Failing Send if the buffered text reaches a limit, say 32K or something,
 seems sensible in the component, rather than expected every user to try
 and understand the buffering.

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

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


Re: [twsocket] HttpSvr send picture stream

2006-11-21 Thread xmedia
Thank you for the code. I have solved the problem. It was caused by other
modules which are not thread safe. The bug ate up HttpSvr's memory space. 

Best regards,
Kyin

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of éric Fleming Bonilha
Sent: Sunday, November 19, 2006 11:58 PM
To: ICS support mailing
Subject: Re: [twsocket] HttpSvr  send picture stream

Hello,

I have developed something similiar to your needs on my application, I have
an HttpSrv that should send an internal stored JPEG to the clients over an
GET request to this JPEG, and it is working just fine, please check this
code, this should be implemented on CommandGET event (ICS 6) (Actually, my
source is written in Delphi, but should be easy to port to C++):

//Create the stream to send the data
StreamImg := TMemoryStream.Create;
try

  //Read the data from my internal JPEG buffer
  Cam.Comunicacao.HTTPImg.ReadImage(StreamImg);

  //Fill the file data and send
  AResponseInfo.ContentType   := 
FHTTP.MIMETable.GetFileMIMEType('.jpg');
  AResponseInfo.ContentLength := StreamImg.Size;
  AResponseInfo.WriteHeader;
  AContext.Connection.IOHandler.Write(StreamImg);

finally
  StreamImg.Free;
end;



- Original Message -
From: xmedia [EMAIL PROTECTED]
To: 'ICS support mailing' twsocket@elists.org
Sent: Sunday, November 19, 2006 1:49 AM
Subject: [twsocket] HttpSvr  send picture stream


 Hello!

 I am trying to send a JPEG stream stored in memory to HttpCli. Below is my
 code. It worked well for first few days and then the server (I mean the
 HttpSvr , not the application) just stopped responding to any http request
 until I restart the application.

 The cause seems to be related to server load. Because I can expediate the
 process by open a few clients requesting pictures at half second 
 interval -
 which can kill the http server over one night. I have been trying very 
 hard
 to find out what's wrong here with no luck. The source file is similar to
 theHttp Svr demo project - except I replaced the Time portion with JPEG
 stream.


 Here is what I put in OnGetDocument:

String URL = ((THttpConnection *)Client)-Path;
if(URL.SubString(1, 6)==/frame)
{

 Flags  = hgWillSendMySelf;
 frame[0]-Position = 0; //frames[0] is where the jpeg file stream
 stored. If saved to disk, you can get a jpeg file.
 String Header = HTTP/1.1 200 OK\r\n
 Content-Type: image/jpeg\r\n
 Content-Length:  + IntToStr(frame[0]-Size)+
 \r\n\r\n;

 TMemoryStream *Stream = new TMemoryStream;
 Stream-Write(Header.data(), Header.Length());
 Stream-CopyFrom(frame[0], 0);
 Stream-Seek(0, 0);

 Flags  = hgWillSendMySelf;
 ((TMyHttpConnection *)Client)-DocStream = Stream;
 ((TMyHttpConnection *)Client)-SendStream();
}

 Thanks - kyin

 -- 
 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] Which TWSocketServer event to capture data sent?

2006-11-21 Thread Wilfried Mestdagh
Hello Clay,

 Maybe a typo error ?
 No, all that code was copied-and-pasted from TCPSrv1.pas.

Maybe you cast the wrong object ?
In a TWSocketSErver event, the Sender argument is TWSocketServer, the
Client argument is your clientclass. In the events of the datasockets
the Sender argument is your client.

This if you have set TWSocketServer's ClientClass to your client class
before you call Listen.

---
Rgds, Wilfried [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html
http://www.mestdagh.biz

-- 
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] What might cause ICS to fail and we need to be aware of?

2006-11-21 Thread Francois Piette
  I don't know of ANY component where it is safe to call the message pump
from
  one of its event without knowing what happend. Even for a simple
  TButton.OnClick, you can get strange result if you call the message pump
  within the OnClick handler because the handler is re-entered. The
problem is
  more visible with TWSocket since it is likely the event is always
reentered
  because of the high rate network I/O has.
 
 
 That's not entirely true. Delphi's GUI model is event-driven so I'm
 willing to bet ANY call to Application.ProcessMessages will be made as a
 result of handling an message or event. And I'm willing to bet most
 calls to Application.ProcessMessages can be traced to ether an
 TButton.OnClick event or a menu item's OnClick!

That's true, but that's just the reverse of the issue !
The issue is to have the message pump called from an event handler. What you
describe is the fact that any event is somewhat called from the message
pump.

If you call the message pump from a simple TButton.OnClick, then the
corresponding event handler may be reentered when the user clicks again on
the button and bad things may happend depending on how the code is written.


 And if it's such a big
 issue for ICS, why isn't there a simple 5-line-of-code test that would
 raise an exception if any code is re-entered?

Because it would need to create a try/finally frame which would have an
impact on the performance given the high rate the events may be triggered
when speaking about network I/O. And it is very easy for the component user
to use a flag to detect reentrancy in his own code.

Anyway, the vast majority of message pump call within an event handler is a
result of the developper not understanding how windows is working. Those
developers add ProcessMessages call to have the screen refreshed or similar
issues. That is frequently not the correct way to do it and it give strange
results in many cases (for example when a user double-click on a simple
button instead of simple click).

 Besides, I'm asking about such behavior because of the way the THttpCli
 component behaves for me. If you remember one of my earlier questions, I
 had lots of problems with the component failing to connect to my HTTP
 server. Using Ethereal I determined the connection is poor (lost
 packets, duplicate ACK's) BUT the component still averages an too high
 number of failed connections. I don't think I've had 5 consecutive
 sessions where no connections timed-out. And I'm saying the failure
 rate is too high because I never saw such a problem using my web
 browser. Not once! And after the time out expires and the component
 aborts and restarts it's Get, it usually finishes very very quickly.
 So I need to ask: Is there some other obvious thing I'm missing, like a
 call to Application.ProcessMessage? What else should I be looking for.

Search for all ProcessMessages and ask yourself if it is really needed. Then
remove it. Thinks about all indirect calls to ProcessMessages such as
displaying any modal dialog box or form.

--
[EMAIL PROTECTED]
Author of ICS (Internet Component Suite, freeware)
Author of MidWare (Multi-tier framework, freeware)
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] HttpCli ContentRangeBegin

2006-11-21 Thread Cosmin Prund
You know, modern hard drives actually checksum written data so you never 
get corrupted data back. You might get NO data back (that is, an I/O 
error) but that would make any operation on the file fail, including 
burning the file to a CD. I've read this in a howto for Linux'es 
software raid driver. That's where they also say the BUS that data 
travels to the HDD is NOT checksummed and that has a grater probability 
of introducing an error!

Also there are two kinds of checksums applied to those large downloads. 
There's the MD5 checksum that can be reproduced by the man in the middle 
so it's useless for security (after all, if the man in the middle is 
willing to waist bandwidth to fake the main download, what does it 
take to also fake the checksum?). And then there are the ASC 
checksums, I think those are used for security as well.

Jack wrote:
 It is actually for data integrity as well (more than security, in my
 opinion.) When it comes to large file download, there might be corrupted
 bytes. Then this is more likely caused by HD errors then network errors.

   
 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.
 


   

-- 
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-21 Thread Jack

It is actually for data integrity as well (more than security, in my
opinion.) When it comes to large file download, there might be corrupted
bytes. Then this is more likely caused by HD errors then network errors.

 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.


-- 
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] TWSocket sync send problem within ISAPI

2006-11-21 Thread Fastream Technologies
I want to add:

1) ISAPI must have sync sockets
2) when I go through breakpoints, no -1's are returned and the sample
jpg returned by the ISAPI extension works perfectly. (no corruption)

Best Regards,

SZ

On 11/21/06, Fastream Technologies [EMAIL PROTECTED] wrote:
 Hello,

 In our ISAPI server, if the request is detected to be of a ISAPI
 interpreter one, we run the routine,


 OldDataAvailable = FOnDataAvailable;
 OldSendData = FOnSendData;
 OldDataSent = FOnDataSent;
 FOnDataAvailable = NULL;
 FOnSendData = NULL;
 FOnDataSent = NULL;

 int iMode = 0;
 WSocket_ioctlsocket(HSocket, FIONBIO, iMode);
 iMode = 1; // as suggested by this group sometime ago

 then we in the callback function of ISAPI for writing to socket, we have,

 function TWebConnection.SendSync(Data: PChar; DataLen: Integer): boolean;
 var
Count: int64;
 begin
if FTerminated or
(State  wsConnected) then
begin
Result := false;
Exit;
end;

Count := WSocket_send(HSocket,
TWSocketData(Data),
DataLen,
0);

Result := Count  0; // COUNT IS MOSTLY -1

if FTerminated or (Result = false) then
begin
Result := false;
Exit;
end;

if Result = true then
DataSent := DataSent + Count;

if FTerminated or
(State  wsConnected) then
begin
Result := false;
end;
 end;

 What could be the reason? Any idea?

 Best Regards,

 SZ

-- 
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] Which TWSocketServer event to capture data sent?

2006-11-21 Thread Arno Garrels
Clay Shannon wrote:
 
 ESocketException - Error 10048 in function Bind Address already in
 use. 

Another socket is already listening on the same IP and port.

---
Arno Garrels [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html
 
-- 
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] TWSocket sync send problem within ISAPI

2006-11-21 Thread Francois Piette
 What could be the reason? Any idea?

Cal WSAGetLastError to know the error code.
--
[EMAIL PROTECTED]
Author of ICS (Internet Component Suite, freeware)
Author of MidWare (Multi-tier framework, freeware)
http://www.overbyte.be

- Original Message - 
From: Fastream Technologies [EMAIL PROTECTED]
To: ICS support mailing twsocket@elists.org
Sent: Tuesday, November 21, 2006 1:09 PM
Subject: [twsocket] TWSocket sync send problem within ISAPI


 Hello,
 
 In our ISAPI server, if the request is detected to be of a ISAPI
 interpreter one, we run the routine,
 
 
 OldDataAvailable = FOnDataAvailable;
 OldSendData = FOnSendData;
 OldDataSent = FOnDataSent;
 FOnDataAvailable = NULL;
 FOnSendData = NULL;
 FOnDataSent = NULL;
 
 int iMode = 0;
 WSocket_ioctlsocket(HSocket, FIONBIO, iMode);
 iMode = 1; // as suggested by this group sometime ago
 
 then we in the callback function of ISAPI for writing to socket, we have,
 
 function TWebConnection.SendSync(Data: PChar; DataLen: Integer): boolean;
 var
 Count: int64;
 begin
 if FTerminated or
 (State  wsConnected) then
 begin
 Result := false;
 Exit;
 end;
 
 Count := WSocket_send(HSocket,
 TWSocketData(Data),
 DataLen,
 0);
 
 Result := Count  0; // COUNT IS MOSTLY -1
 
 if FTerminated or (Result = false) then
 begin
 Result := false;
 Exit;
 end;
 
 if Result = true then
 DataSent := DataSent + Count;
 
 if FTerminated or
 (State  wsConnected) then
 begin
 Result := false;
 end;
 end;
 
 What could be the reason? Any idea?
 
 Best Regards,
 
 SZ
 -- 
 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] Need example code for identifying a recordbeforeprocessing

2006-11-21 Thread Clay Shannon
 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.

So sending records from a C program running on Linux to a Delphi app running
on Windows would result in being unable to easily unpack the record? IOW,
the C struct will not convert/translate to a Delphi record easily?

If so, I think delimited strings will definitely have to be our solution.

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Francois PIETTE
Sent: Saturday, November 18, 2006 7:26 AM
To: ICS support mailing
Subject: Re: [twsocket] Need example code for identifying a
recordbeforeprocessing

 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

The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material.  If the reader of this message is not the intended recipient,
you are hereby notified that your access is unauthorized, and any review,
dissemination, distribution or copying of this message including any
attachments is strictly prohibited.   If you are not the intended
recipient, please contact the sender and delete the material from any
computer.
-- 
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 foridentifyingarecordbeforeprocessing

2006-11-21 Thread Clay Shannon
Oh, never mind, I see it in your other answer now (I'm reading answers
posted over the weekend and this mailing list (live) simultaneously),
namely:

MyOpCode := PInteger(@Buffer)^;

Thanks, Francois!

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Clay Shannon
Sent: Monday, November 20, 2006 10:04 AM
To: 'ICS support mailing'
Subject: Re: [twsocket] Need example code
foridentifyingarecordbeforeprocessing

 Right. But since you send integer data type, you WILL have #126 in the
binary data !

In the infamous words of Kip Dynamite, Dang it

Is there any LineEnd value I can set that will be safe to assume it won't
get sent in integer data?

Or will I need to pull out the OpCode any time a record comes in, without
knowing which type of record it is until I read the OpCode?

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Francois Piette
Sent: Monday, November 20, 2006 9:59 AM
To: ICS support mailing
Subject: Re: [twsocket] Need example code for
identifyingarecordbeforeprocessing

  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 !

 But only if a tilde (#126) is included in the binary data sent, right?

Right. But since you send integer data type, you WILL have #126 in the
binary data !

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

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


The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material.  If the reader of this message is not the intended recipient,
you are hereby notified that your access is unauthorized, and any review,
dissemination, distribution or copying of this message including any
attachments is strictly prohibited.   If you are not the intended
recipient, please contact the sender and delete the material from any
computer.
-- 
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] What might cause ICS to fail and we need to be aware of?

2006-11-21 Thread Frans van Daalen

- Original Message - 
From: Cosmin Prund [EMAIL PROTECTED]
To: ICS support mailing twsocket@elists.org
Sent: Monday, November 20, 2006 10:16 AM
Subject: Re: [twsocket] What might cause ICS to fail and we need to be aware 
of?


 Francois Piette wrote:
 I don't know of ANY component where it is safe to call the message pump 
 from
 one of its event without knowing what happend. Even for a simple
 TButton.OnClick, you can get strange result if you call the message pump
 within the OnClick handler because the handler is re-entered. The problem 
 is
 more visible with TWSocket since it is likely the event is always 
 reentered
 because of the high rate network I/O has.


 That's not entirely true. Delphi's GUI model is event-driven so I'm
 willing to bet ANY call to Application.ProcessMessages will be made as a
 result of handling an message or event. And I'm willing to bet most
 calls to Application.ProcessMessages can be traced to ether an
 TButton.OnClick event or a menu item's OnClick! And if it's such a big
 issue for ICS, why isn't there a simple 5-line-of-code test that would
 raise an exception if any code is re-entered?


Why ? It is correct that it should enter that event. Incorrect use of 
processmessage lead to the incorrect moment of entry!

 Besides, I'm asking about such behavior because of the way the THttpCli
 component behaves for me. If you remember one of my earlier questions, I
 had lots of problems with the component failing to connect to my HTTP
 server. Using Ethereal I determined the connection is poor (lost
 packets, duplicate ACK's) BUT the component still averages an too high
 number of failed connections. I don't think I've had 5 consecutive
 sessions where no connections timed-out. And I'm saying the failure
 rate is too high because I never saw such a problem using my web
 browser. Not once! And after the time out expires and the component
 aborts and restarts it's Get, it usually finishes very very quickly.
 So I need to ask: Is there some other obvious thing I'm missing, like a
 call to Application.ProcessMessage? What else should I be looking for.

So did you trace you browser then ? My gues is that there are as many 
failures but they are handled by the browser. You could do that as well in 
you application. It is not the responsibility of the httpcli component.

repeat
   try
 xxx.get
 callok := true
   except
 inc(tried)
   end
until callok or tried5 

-- 
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] Which TWSocketServer event to capture data sent?

2006-11-21 Thread Clay Shannon
If I add this line of code (from TcpSrv1.pas):

  PostMessage(Handle, WM_APPSTARTUP, 0, 0);

To the FormShow() event, I get this error msg:

ESocketException - Error 10048 in function Bind Address already in use.

On the last line (Listen) of this code:

procedure TfClientMain.WMAppStartup(var Msg: TMessage);
begin
  WSocketServer.Proto   := 'tcp'; { Use TCP protocol  }
  WSocketServer.Port:= '1234';{ Use telnet port -- changed
to 1234 }
  WSocketServer.Addr:= '0.0.0.0'; { Use any interface }
  WSocketServer.ClientClass := TTcpSrvClient; { Use our component }
  WSocketServer.Listen;   -- here
end;

Before WSocketServer1ClientConnect() is even reached.

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Clay Shannon
Sent: Monday, November 20, 2006 4:20 PM
To: 'ICS support mailing'
Subject: Re: [twsocket] Which TWSocketServer event to capture data sent?

 See TTcpSrvForm.WSocketServer1ClientConnect in TcpSrv1.pas source.

When I try to use that code, I get an EInvalidCast error, specifically,
EInvalidCast - Invalid class typecast on this line:

  with Client as TTcpSrvClient do begin

of the OnClientConnect() event handler.

And this even though my class definition and OnClientConnect() code were
copied verbatim from the TcpSrv1.pas.

I have also copied most of the code from the TcpSrv1 unit, including but not
limited to:

procedure ClientDataAvailable(Sender: TObject; Error: Word);
procedure ClientBgException(Sender   : TObject;
E: Exception;
var CanClose : Boolean);
procedure ClientLineLimitExceeded(Sender: TObject;
  Cnt   : LongInt;
  var ClearData : Boolean);
procedure WMAppStartup(var Msg: TMessage); message WM_APPSTARTUP;

Why would I get EInvalidCast when TcpSrv doesn't, although the cast and the
custom class are the same?


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Francois PIETTE
Sent: Monday, November 20, 2006 2:19 PM
To: ICS support mailing
Subject: Re: [twsocket] Which TWSocketServer event to capture data sent?

 Which TWSocketServer event should I code to retrieve incoming data?

None !
Data doesn't come from TWSocketServer but from one TWSocketClient (another 
TWSocket derived class) which is instanciated for each incomming connection.

See how it works in TcpSrv sample program.

 The two that fire when I send the data are:
 1)   WSocketServerSessionAvailable()
 2)   WSocketServerClientConnect()

Normal for a listening socket.

 It seems the WSocketServerDataAvailable() and/or WSocketServerDataSent()
 events should fire.

Defenitely not !

 Do I need to do anything with the TWSocketServer
 component to get these to fire, or can I safely read the incoming data in
 one of the two events above (Once a connection is made, data will be sent
 multiple times, so I don't know if those events get called over and over,
 or.?

See TTcpSrvForm.WSocketServer1ClientConnect in TcpSrv1.pas source. This 
event handler associate an OnDataAvailable event handler to the 
TWSocketClient instance created by the server component to handle a client 
connection.

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


The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material.  If the reader of this message is not the intended recipient,
you are hereby notified that your access is unauthorized, and any review,
dissemination, distribution or copying of this message including any
attachments is strictly prohibited.   If you are not the intended
recipient, please contact the sender and delete the material from any
computer.
-- 
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] Which TWSocketServer event to capture data sent?

2006-11-21 Thread Francois Piette
  See TTcpSrvForm.WSocketServer1ClientConnect in TcpSrv1.pas source.

 When I try to use that code, I get an EInvalidCast error, specifically,
 EInvalidCast - Invalid class typecast on this line:

   with Client as TTcpSrvClient do begin

 of the OnClientConnect() event handler.


TWSocketServer instanciate a new TWSocket component for each incomming
connection. The exact class instanciated is governed by
TWSocketServer.ClientClass. As you can see in TcpSrv sample program, you
have to define your own class (TTcpSrvClient in the demo) deriving form
TWSocketClient and having all the features you need to handle YOUR client
connection.

In all event handlers, TWSocketServer pass a Client argument of the base
type TWSocketClient which you must cast to YOUR type.

 Why would I get EInvalidCast when TcpSrv doesn't, although the cast and
the
 custom class are the same?

Maybe a typo error ?

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

-- 
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] How server can send data to clients ?

2006-11-21 Thread Francois PIETTE
 I have a TWSocketServer which is listening incoming clients connections.
 Once a client is connected, the server send data to it.
 Sometimes, I need this client to send command to the server.
 Is it possible with ics components ?
 If yes, how can I do it ?

When the client is connected to the server, you have a bi-directionnal 
communication channel. The server can send data to client and client can 
send data to the server.

If the client isn't connected, the server has no way to send anything to the 
client. By definition a client is the one which initiate a connection and a 
server is the one which passively wait for incomming connections.

Of course nothing prevent your client to be also a server !

Speaking about TWSocketServer, you have an indexed property Client[] which 
allows the developper to access to any connected client. You -have 
ClientCount property telling the size of the client array. You can do 
something like that (Not tested, just tuyped here in the message):

for i := 0 to WSocketServer1.ClientCount - 1 do
WSocketServer1.Client[I].SendStr('Hello World'#13#10);


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


[twsocket] Posting data to web server using THttpCli under user control

2006-11-21 Thread Cosmin Prund
Hello everyone.

I'm using THttpServer to send a document myself (using hgWillSendMySelf) 
so I can keep sending new data without requiring a new connection. It 
works just fine. Now I want to do the same the other way around: I want 
to use THttpCli to continually post data, without closing the connection.

Is it possible?
Will it work through an HTTP proxy?

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] What might cause ICS to fail and we need to be aware of?

2006-11-21 Thread Cosmin Prund
Francois Piette wrote:
 I don't know of ANY component where it is safe to call the message pump from
 one of its event without knowing what happend. Even for a simple
 TButton.OnClick, you can get strange result if you call the message pump
 within the OnClick handler because the handler is re-entered. The problem is
 more visible with TWSocket since it is likely the event is always reentered
 because of the high rate network I/O has.

   
That's not entirely true. Delphi's GUI model is event-driven so I'm 
willing to bet ANY call to Application.ProcessMessages will be made as a 
result of handling an message or event. And I'm willing to bet most 
calls to Application.ProcessMessages can be traced to ether an 
TButton.OnClick event or a menu item's OnClick! And if it's such a big 
issue for ICS, why isn't there a simple 5-line-of-code test that would 
raise an exception if any code is re-entered?

Besides, I'm asking about such behavior because of the way the THttpCli 
component behaves for me. If you remember one of my earlier questions, I 
had lots of problems with the component failing to connect to my HTTP 
server. Using Ethereal I determined the connection is poor (lost 
packets, duplicate ACK's) BUT the component still averages an too high 
number of failed connections. I don't think I've had 5 consecutive 
sessions where no connections timed-out. And I'm saying the failure 
rate is too high because I never saw such a problem using my web 
browser. Not once! And after the time out expires and the component 
aborts and restarts it's Get, it usually finishes very very quickly. 
So I need to ask: Is there some other obvious thing I'm missing, like a 
call to Application.ProcessMessage? What else should I be looking for.

--
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] How server can send data to clients ?

2006-11-21 Thread Engi
Thanks

- Original Message - 
From: Francois PIETTE [EMAIL PROTECTED]
To: ICS support mailing twsocket@elists.org
Sent: Monday, November 20, 2006 8:04 PM
Subject: Re: [twsocket] How server can send data to clients ?


 it's ok for the server part ?
 is it the same method for the client part (to send data to server) ?
 
 No matter which side you are talking about. It is the same class - 
 TWSocket - which handle the connection at both ends. So the methods, 
 properties and events are the same.
 
 --
 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


Re: [twsocket] Using Imap

2006-11-21 Thread Francois Piette
There is no IMAP component in ICS. Sorry.
Maybe you'll write it ?

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: Bjørnar Nielsen [EMAIL PROTECTED]
To: 'ICS support mailing' twsocket@elists.org
Sent: Monday, November 20, 2006 11:30 AM
Subject: [twsocket] Using Imap


I can't see a component for Imap in the ICS-package.

I have never used IMAP and don't know much about this protocol, but now have
a customer that needs support for this. Does anyone in this list have any
tip for IMAP-components that works well with ICS?

Regards Bjørnar
-- 
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] Need example code for identifying a recordbeforeprocessing

2006-11-21 Thread Clay Shannon
 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 !

But only if a tilde (#126) is included in the binary data sent, right?

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Francois PIETTE
Sent: Saturday, November 18, 2006 7:26 AM
To: ICS support mailing
Subject: Re: [twsocket] Need example code for identifying a
recordbeforeprocessing

 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

The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material.  If the reader of this message is not the intended recipient,
you are hereby notified that your access is unauthorized, and any review,
dissemination, distribution or copying of this message including any
attachments is strictly prohibited.   If you are not the intended
recipient, please contact the sender and delete the material from any
computer.
-- 
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] How server can send data to clients ?

2006-11-21 Thread Francois PIETTE
 it's ok for the server part ?
 is it the same method for the client part (to send data to server) ?

No matter which side you are talking about. It is the same class - 
TWSocket - which handle the connection at both ends. So the methods, 
properties and events are the same.

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


[twsocket] How server can send data to clients ?

2006-11-21 Thread Engi
Hi,

I have a TWSocketServer which is listening incoming clients connections.
Once a client is connected, the server send data to it.
Sometimes, I need this client to send command to the server.
Is it possible with ics components ?
If yes, how can I do it ?

TIA,
Engi
-- 
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] TWSocket sync send problem within ISAPI

2006-11-21 Thread Fastream Technologies
Hello,

In our ISAPI server, if the request is detected to be of a ISAPI
interpreter one, we run the routine,


OldDataAvailable = FOnDataAvailable;
OldSendData = FOnSendData;
OldDataSent = FOnDataSent;
FOnDataAvailable = NULL;
FOnSendData = NULL;
FOnDataSent = NULL;

int iMode = 0;
WSocket_ioctlsocket(HSocket, FIONBIO, iMode);
iMode = 1; // as suggested by this group sometime ago

then we in the callback function of ISAPI for writing to socket, we have,

function TWebConnection.SendSync(Data: PChar; DataLen: Integer): boolean;
var
Count: int64;
begin
if FTerminated or
(State  wsConnected) then
begin
Result := false;
Exit;
end;

Count := WSocket_send(HSocket,
TWSocketData(Data),
DataLen,
0);

Result := Count  0; // COUNT IS MOSTLY -1

if FTerminated or (Result = false) then
begin
Result := false;
Exit;
end;

if Result = true then
DataSent := DataSent + Count;

if FTerminated or
(State  wsConnected) then
begin
Result := false;
end;
end;

What could be the reason? Any idea?

Best Regards,

SZ
-- 
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] What might cause ICS to fail and we need to be aware of?

2006-11-21 Thread Cosmin Prund
Francois Piette wrote:
 Because it would need to create a try/finally frame which would have an
 impact on the performance given the high rate the events may be triggered
 when speaking about network I/O. And it is very easy for the component user
 to use a flag to detect reentrancy in his own code.

   

A try/finally frame does not have a significant impact on performance IF 
no exception is actually raised. I've done some tests on my 2,21Ghz AMD 
64 X2: adding a standard frame adds about 0.2312 milliseconds to a 
call. In other words, 1 millisecond every 5000 calls. I've done the 
measuring in a loop that ran for 1 (that's 100 million times so 
you don't need to count the zero's).
 Anyway, the vast majority of message pump call within an event handler is a
 result of the developper not understanding how windows is working. Those
 developers add ProcessMessages call to have the screen refreshed or similar
 issues. That is frequently not the correct way to do it and it give strange
 results in many cases (for example when a user double-click on a simple
 button instead of simple click).

   

That's true.
 Besides, I'm asking about such behavior because of the way the THttpCli
 component behaves for me. If you remember one of my earlier questions, I
 had lots of problems with the component failing to connect to my HTTP
 server. Using Ethereal I determined the connection is poor (lost
 packets, duplicate ACK's) BUT the component still averages an too high
 number of failed connections. I don't think I've had 5 consecutive
 sessions where no connections timed-out. And I'm saying the failure
 rate is too high because I never saw such a problem using my web
 browser. Not once! And after the time out expires and the component
 aborts and restarts it's Get, it usually finishes very very quickly.
 So I need to ask: Is there some other obvious thing I'm missing, like a
 call to Application.ProcessMessage? What else should I be looking for.
 

 Search for all ProcessMessages and ask yourself if it is really needed. Then
 remove it. Thinks about all indirect calls to ProcessMessages such as
 displaying any modal dialog box or form.
   

All ProcessMessages calls are accounted for; None would run from within 
an ICS event handler. And if you must know what I'm using 
ProcessMessages for I'll tell you: I'm running my own ShowModal variant 
because the built-in one is not flexible enough.

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


[twsocket] Using Imap

2006-11-21 Thread Bjørnar Nielsen
I can't see a component for Imap in the ICS-package.
 
I have never used IMAP and don't know much about this protocol, but now have
a customer that needs support for this. Does anyone in this list have any
tip for IMAP-components that works well with ICS?
 
Regards Bjørnar
-- 
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] How server can send data to clients ?

2006-11-21 Thread Engi
it's ok for the server part ?

is it the same method for the client part (to send data to server) ?


- Original Message - 
From: Francois PIETTE [EMAIL PROTECTED]
To: ICS support mailing twsocket@elists.org
Sent: Monday, November 20, 2006 6:56 PM
Subject: Re: [twsocket] How server can send data to clients ?


 I have a TWSocketServer which is listening incoming clients connections.
 Once a client is connected, the server send data to it.
 Sometimes, I need this client to send command to the server.
 Is it possible with ics components ?
 If yes, how can I do it ?

 When the client is connected to the server, you have a bi-directionnal
 communication channel. The server can send data to client and client can
 send data to the server.

 If the client isn't connected, the server has no way to send anything to 
 the
 client. By definition a client is the one which initiate a connection and 
 a
 server is the one which passively wait for incomming connections.

 Of course nothing prevent your client to be also a server !

 Speaking about TWSocketServer, you have an indexed property Client[] which
 allows the developper to access to any connected client. You -have
 ClientCount property telling the size of the client array. You can do
 something like that (Not tested, just tuyped here in the message):

 for i := 0 to WSocketServer1.ClientCount - 1 do
WSocketServer1.Client[I].SendStr('Hello World'#13#10);


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


[twsocket] Still rassling with sending and receiving

2006-11-21 Thread Clay Shannon
When I send a string from my test utility, the ClientConnect() event(*)
fires in my app, which is listening for messages, but the
ClientDataAvailable() event(**) is not fired. 

 

And when I send the message a second time from the test utility, I get
Connect: socket already in use.

 

Also, the sending utility freezes up after sending the message.

 

{ Taken from the ICS demo }

procedure TfClientMain.WSocketServerClientConnect(Sender: TObject; Client:
TWSocketClient; Error: Word);

begin

  with Client as TTcpSrvClient do begin

ShowMessage('Client connected.' +

' Remote: ' + PeerAddr + '/' + PeerPort +

' Local: '  + GetXAddr + '/' + GetXPort);

ShowMessage('There is now ' +

IntToStr(TWSocketServer(Sender).ClientCount) +

' client(s) connected.');

LineMode:= TRUE;

LineEdit:= TRUE;

LineLimit   := 255; { Do not accept long lines } //changed from
255

OnDataAvailable := ClientDataAvailable;

OnLineLimitExceeded := ClientLineLimitExceeded;

OnBgException   := ClientBgException;

ConnectTime := Now;

  end;

end;

 

{ Taken from the ICS demo, too -- this event never gets fired }

procedure TfClientMain.ClientDataAvailable(Sender: TObject; Error: Word);

begin

  with Sender as TTcpSrvClient do begin

{ We use line mode. We will receive complete lines }

RcvdLine := ReceiveStr;

{ Remove trailing CR/LF }

while (Length(RcvdLine)  0) and

  (RcvdLine[Length(RcvdLine)] in [#13, #10]) do

  RcvdLine := Copy(RcvdLine, 1, Length(RcvdLine) - 1);

ShowMessage('Received from ' + GetPeerAddr + ': ''' + RcvdLine + );

//ProcessData(Sender as TTcpSrvClient);

  end;

end;

 

I must be missing something yet...

The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material.  If the reader of this message is not the intended recipient,
you are hereby notified that your access is unauthorized, and any review,
dissemination, distribution or copying of this message including any
attachments is strictly prohibited.   If you are not the intended
recipient, please contact the sender and delete the material from any
computer.
-- 
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 arecordbeforeprocessing

2006-11-21 Thread Francois PIETTE
  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.

 So sending records from a C program running on Linux to a Delphi app 
 running
 on Windows would result in being unable to easily unpack the record?

Not only different languages may represent data types differently (specially 
for string, floting point, date and time) but different processors will 
represent data differently (some processors are big endian others are 
little endian. If you don't know what it is, google is your friend :-)

 IOW, the C struct will not convert/translate to a Delphi record easily?

It depends what is in a C struct.
Without mention to data alignement problems (true for any language).

 If so, I think delimited strings will definitely have to be our solution.

Yes, it is a very good solution.
The only drawback is somewhat slower because you have to convert to/from 
ascii to the binary data and the data size is somewhat larger. Most well 
known TCP/IP protocols are ascii based.

--
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] Which TWSocketServer event to capture data sent?

2006-11-21 Thread Clay Shannon
 See TTcpSrvForm.WSocketServer1ClientConnect in TcpSrv1.pas source.

When I try to use that code, I get an EInvalidCast error, specifically,
EInvalidCast - Invalid class typecast on this line:

  with Client as TTcpSrvClient do begin

of the OnClientConnect() event handler.

And this even though my class definition and OnClientConnect() code were
copied verbatim from the TcpSrv1.pas.

I have also copied most of the code from the TcpSrv1 unit, including but not
limited to:

procedure ClientDataAvailable(Sender: TObject; Error: Word);
procedure ClientBgException(Sender   : TObject;
E: Exception;
var CanClose : Boolean);
procedure ClientLineLimitExceeded(Sender: TObject;
  Cnt   : LongInt;
  var ClearData : Boolean);
procedure WMAppStartup(var Msg: TMessage); message WM_APPSTARTUP;

Why would I get EInvalidCast when TcpSrv doesn't, although the cast and the
custom class are the same?


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Francois PIETTE
Sent: Monday, November 20, 2006 2:19 PM
To: ICS support mailing
Subject: Re: [twsocket] Which TWSocketServer event to capture data sent?

 Which TWSocketServer event should I code to retrieve incoming data?

None !
Data doesn't come from TWSocketServer but from one TWSocketClient (another 
TWSocket derived class) which is instanciated for each incomming connection.

See how it works in TcpSrv sample program.

 The two that fire when I send the data are:
 1)   WSocketServerSessionAvailable()
 2)   WSocketServerClientConnect()

Normal for a listening socket.

 It seems the WSocketServerDataAvailable() and/or WSocketServerDataSent()
 events should fire.

Defenitely not !

 Do I need to do anything with the TWSocketServer
 component to get these to fire, or can I safely read the incoming data in
 one of the two events above (Once a connection is made, data will be sent
 multiple times, so I don't know if those events get called over and over,
 or.?

See TTcpSrvForm.WSocketServer1ClientConnect in TcpSrv1.pas source. This 
event handler associate an OnDataAvailable event handler to the 
TWSocketClient instance created by the server component to handle a client 
connection.

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

The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material.  If the reader of this message is not the intended recipient,
you are hereby notified that your access is unauthorized, and any review,
dissemination, distribution or copying of this message including any
attachments is strictly prohibited.   If you are not the intended
recipient, please contact the sender and delete the material from any
computer.
-- 
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] What might cause ICS to fail and we need to be aware of?

2006-11-21 Thread Francois Piette
 I noticed something.

 If in the OnDocData event handler of THttpCli I somehow re-enter the
 message pump (that is, do something that calls
 Application.HandleMessage or Application.ProcessMessages) the downloaded
 file is corrupted! It took me a while to find this out and now I'm asking:

 (1) What do I do to protect myself from something like this. When
 working with 3rd party components you don't always know what's behind
 the code and 3rd party components might do Application.HandleMessage or
 Application.ProcessMessage without advertising it. Is there something I
 can do so I can raise an error if the code in OnDocData caused an
 dangerous message to be processed?

I don't know of ANY component where it is safe to call the message pump from
one of its event without knowing what happend. Even for a simple
TButton.OnClick, you can get strange result if you call the message pump
within the OnClick handler because the handler is re-entered. The problem is
more visible with TWSocket since it is likely the event is always reentered
because of the high rate network I/O has.

 (2) Are there other such traps one needs to be aware of?
 Like not implementing timeout?

Destroying the component from one of its event handlers. Again this is the
same issue as with ANY other component. I don't think there are specific
traps. Of course anything can be a trap if you don't know how things
works...

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

-- 
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] Which TWSocketServer event to capture data sent?

2006-11-21 Thread Francois Piette
 If I add this line of code (from TcpSrv1.pas):

   PostMessage(Handle, WM_APPSTARTUP, 0, 0);

 To the FormShow() event, I get this error msg:

 ESocketException - Error 10048 in function Bind Address already in use.

Error 10048 occurs when you try to make a socket listening on a port alreay
used for listening. Only one socket at a time may listen on a given IP:PORT.
That's how Winsock work.

Error 10048 frequently happend when you start your server program twice.

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


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

2006-11-21 Thread Francois PIETTE
  Right. But since you send integer data type, you WILL have #126 in the
 binary data !

 In the infamous words of Kip Dynamite, Dang it

 Is there any LineEnd value I can set that will be safe to assume it won't
 get sent in integer data?

Defenitely none !

 Or will I need to pull out the OpCode any time a record comes in, without
 knowing which type of record it is until I read the OpCode?

You can.
Or you can follow my recommandation about escaping delimiter. This is very 
common practice with binary data.
Or send your data in ascii.
Did you miss my previous reply where I was talking about binary data and 
excape mechanism ?

--
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] Flow control

2006-11-21 Thread Arno Garrels
Francois PIETTE wrote:
 
 IMO, you have all the required tools !

Yes, no question, you realy have all the required tools. But you
also have the required tools to write a SMTP client using TWSocket,
and nevertheless there's a SMTP client in ICS. What I mean is that
it won't hurt to put that in, but I can live happily w/o such a
feature.

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

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

2006-11-21 Thread Fastream Technologies
Here is an idea: (HTTP uses this logic). Send a header with the
content-length first then cut the data wrt that.

Regards,

SZ

On 11/20/06, Francois PIETTE [EMAIL PROTECTED] wrote:
   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.
 
  So sending records from a C program running on Linux to a Delphi app
  running
  on Windows would result in being unable to easily unpack the record?

 Not only different languages may represent data types differently (specially
 for string, floting point, date and time) but different processors will
 represent data differently (some processors are big endian others are
 little endian. If you don't know what it is, google is your friend :-)

  IOW, the C struct will not convert/translate to a Delphi record easily?

 It depends what is in a C struct.
 Without mention to data alignement problems (true for any language).

  If so, I think delimited strings will definitely have to be our solution.

 Yes, it is a very good solution.
 The only drawback is somewhat slower because you have to convert to/from
 ascii to the binary data and the data size is somewhat larger. Most well
 known TCP/IP protocols are ascii based.

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



-- 
CSA, Fastream Technologies
Software IQ: Innovation  Quality
www.fastream.com | Email: [EMAIL PROTECTED] | Tel: +90-312-223-2830
-- 
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] Which TWSocketServer event to capture data sent?

2006-11-21 Thread Clay Shannon
Which TWSocketServer event should I code to retrieve incoming data?

 

I'm sending data from a test util (using TWSocket), and have SHowMessage()
code in the following events:

 

WSocketServerClientConnect()

WSocketServerDataAvailable()

WSocketServerDataSent()

WSocketServerSendData()

WSocketServerSessionAvailable()

WSocketServerSessionConnected()

 

The two that fire when I send the data are:

 

1)   WSocketServerSessionAvailable()

2)   WSocketServerClientConnect()

 

It seems the WSocketServerDataAvailable() and/or WSocketServerDataSent()
events should fire. Do I need to do anything with the TWSocketServer
component to get these to fire, or can I safely read the incoming data in
one of the two events above (Once a connection is made, data will be sent
multiple times, so I don't know if those events get called over and over,
or.?

The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material.  If the reader of this message is not the intended recipient,
you are hereby notified that your access is unauthorized, and any review,
dissemination, distribution or copying of this message including any
attachments is strictly prohibited.   If you are not the intended
recipient, please contact the sender and delete the material from any
computer.
-- 
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-21 Thread Clay Shannon
 I don't understand what you real app is. It is your server
application?

Yes. I'm trying to send it the data from a test util (in actuality, the data
will come from a real-time system).

Is it built using TWSocketServer ?

Not right now.

Don't use TWSocket for listening, use TWSocketServer which do all the
housekeeping needed to handle simultaneous clients.

OK -- I was using the Client5 and Server5 demos as a starting point, where
both the sender and receiver are TWSocket components, are they not?

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Francois PIETTE
Sent: Saturday, November 18, 2006 3:12 AM
To: ICS support mailing
Subject: Re: [twsocket] Pulling my hair out trying to receive a record

  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;

  { 

[twsocket] Overview of TICSLogger?

2006-11-21 Thread Clay Shannon
Can somebody point me to documentation that gives an overview of what
TICSLogger does and how to use it? Is there a demo that features it?

The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material.  If the reader of this message is not the intended recipient,
you are hereby notified that your access is unauthorized, and any review,
dissemination, distribution or copying of this message including any
attachments is strictly prohibited.   If you are not the intended
recipient, please contact the sender and delete the material from any
computer.
-- 
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] Posting data to web server using THttpCli under usercontrol

2006-11-21 Thread Francois Piette
 I'm using THttpServer to send a document myself (using hgWillSendMySelf)
 so I can keep sending new data without requiring a new connection. It
 works just fine. Now I want to do the same the other way around: I want
 to use THttpCli to continually post data, without closing the
connection.

You can have a HTTP post which never ends. But probably it is not what you
really want. Since you control the client part, why not send as many HTTP
requests as you need ?

 without closing the connection.

You have not full control of connection close with HTTP protocol. If the
server decide to close it, it will be closed. You can request a persistant
connection using the property Connection and setting 'keep-alive' string as
value. See also ProxyConnection property used when traversing a proxy.

 Is it possible?
 Will it work through an HTTP proxy?

A post which never ends may have problem with filtering proxies because they
will not see the end of document and maybe they are buffering the document
until the end before processing it. So it would not works. If you use many
post one after the other, there will be no special problem.

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

-- 
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] TWSocket sync send problem within ISAPI

2006-11-21 Thread Francois PIETTE
I do not think the issue understood the same here and there. Why is
 the Count = -1 then?

When you call Send, passing a number of bytes and send is not able to send 
it without blocking and non-blocking mode is active, then send returns -1 to 
tell you it can't do what you asked. Nothing is sent. WSAGetLastError tells 
you what exactly happended.

 What should one do to have the sync method work?

ICS doesn't use blocking mode. Trying to change that without knowing exactly 
what you are doing will result in unexpected results - as you can see.

You'd better design your code to use non blocking mode.
If ISAPI is what you want, have a look at IcsIsap1.pas in the demos.

--
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] TWSocket sync send problem within ISAPI

2006-11-21 Thread Fastream Technologies
Hello Francois,

Thanks for the pointer. The error is 10035.

Best Regards,

SZ

On 11/21/06, Francois Piette [EMAIL PROTECTED] wrote:
  What could be the reason? Any idea?

 Cal WSAGetLastError to know the error code.
 --
 [EMAIL PROTECTED]
 Author of ICS (Internet Component Suite, freeware)
 Author of MidWare (Multi-tier framework, freeware)
 http://www.overbyte.be

 - Original Message -
 From: Fastream Technologies [EMAIL PROTECTED]
 To: ICS support mailing twsocket@elists.org
 Sent: Tuesday, November 21, 2006 1:09 PM
 Subject: [twsocket] TWSocket sync send problem within ISAPI


  Hello,
 
  In our ISAPI server, if the request is detected to be of a ISAPI
  interpreter one, we run the routine,
 
 
  OldDataAvailable = FOnDataAvailable;
  OldSendData = FOnSendData;
  OldDataSent = FOnDataSent;
  FOnDataAvailable = NULL;
  FOnSendData = NULL;
  FOnDataSent = NULL;
 
  int iMode = 0;
  WSocket_ioctlsocket(HSocket, FIONBIO, iMode);
  iMode = 1; // as suggested by this group sometime ago
 
  then we in the callback function of ISAPI for writing to socket, we have,
 
  function TWebConnection.SendSync(Data: PChar; DataLen: Integer): boolean;
  var
  Count: int64;
  begin
  if FTerminated or
  (State  wsConnected) then
  begin
  Result := false;
  Exit;
  end;
 
  Count := WSocket_send(HSocket,
  TWSocketData(Data),
  DataLen,
  0);
 
  Result := Count  0; // COUNT IS MOSTLY -1
 
  if FTerminated or (Result = false) then
  begin
  Result := false;
  Exit;
  end;
 
  if Result = true then
  DataSent := DataSent + Count;
 
  if FTerminated or
  (State  wsConnected) then
  begin
  Result := false;
  end;
  end;
 
  What could be the reason? Any idea?
 
  Best Regards,
 
  SZ
  --
  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] Which TWSocketServer event to capture data sent?

2006-11-21 Thread Time Bandit
 Which TWSocketServer event should I code to retrieve incoming data?
Define a private procedure like this :
  procedure ClientDataAvailable(Sender: TObject; Error: Word);

In the OnClientConnect event, you have to assign an event handler to
your client socket.

Something like this :
  Client.OnDataAvailable := ClientDataAvailable;

Then, when a client will send data, your ClientDataAvailable procedure
will be called.

Have a look at the TcpSrv demo.

hope this help
-- 
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] TWSocket sync send problem within ISAPI

2006-11-21 Thread Fastream Technologies
I do not think the issue understood the same here and there. Why is
the Count = -1 then? What should one do to have the sync method work?
(I have changed the mode to sync, I hope you noticed. See the code I
posted in my __first__ email.)

Regards,

SZ

On 11/21/06, Francois PIETTE [EMAIL PROTECTED] wrote:
  Thanks for the pointer. The error is 10035.

 As you can see in the docs, it is WSAEWOULDBLOCK. This not a real error in a
 non-blocking environment. It just mean the winsock call would block to
 execute the task and non-blocking mode has been selected.

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


Re: [twsocket] Posting data to web server using THttpCliunder usercontrol

2006-11-21 Thread Francois PIETTE
 Using hgWillSendMySelf I noticed the proxy server immediately connects
 the client to the server and the connection is kept open as long as I'm
 sending data. If the proxy server does the same for the long HTTP post
 it would provide a very valuable tool for what I need.

I wouldn't base my software on this behaviour which is defenitely not 
guaranteed. HTTP protocol is a stateless protocol and you have poor 
connection control. Just ask for the connection to be kept alive and hope it 
is. If it isn't, then it will be reopened anyway by the component.


 If it doesn't work I'll simply use as many HTTP posts as necessary.

That is much safer. If you are sure you have ONLY ICS component at both 
side, you can be sure of the behaviour. But anything between has just to be 
compliant with HTTP protocol and what you ask is more.


 On a different note, how do programs like zebedee provide a TCP/IP
 tunnel through a HTTP proxy? I understand how the downstream part
 works, but how about the upstream part?

This is quite easy. You can send the command CONNECT to a HTTP proxy and 
then the proxy will work transparently as a simple relay, without ever 
trying to understand what you send in the stream. This is how HTTPS works 
thru the proxy. Since HTTPS encrypt everything, the proxy is unable to do 
anything. It can just relay the data. That's the purpose of the CONNECT 
command.

--
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] Posting data to web server using THttpCli under usercontrol

2006-11-21 Thread Cosmin Prund
Francois Piette wrote:
 I'm using THttpServer to send a document myself (using hgWillSendMySelf)
 so I can keep sending new data without requiring a new connection. It
 works just fine. Now I want to do the same the other way around: I want
 to use THttpCli to continually post data, without closing the
 
 connection.

 You can have a HTTP post which never ends. But probably it is not what you
 really want. Since you control the client part, why not send as many HTTP
 requests as you need ?

   

Using hgWillSendMySelf I noticed the proxy server immediately connects 
the client to the server and the connection is kept open as long as I'm 
sending data. If the proxy server does the same for the long HTTP post 
it would provide a very valuable tool for what I need. If it doesn't 
work I'll simply use as many HTTP posts as necessary. And if it makes 
any difference, for this part of my application I control both the 
client and the server; It's the potential proxy in the middle I'm 
not controlling. I need to use HTTP to make sure it works through the proxy.

On a different note, how do programs like zebedee provide a TCP/IP 
tunnel through a HTTP proxy? I understand how the downstream part 
works, but how about the upstream part?

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] Still rassling with sending and receiving

2006-11-21 Thread Wilfried Mestdagh
Hello Clay,

 OK, by going over the clidemo and TCPServ projects (which successfully
 communicate with each other) with a fine-toothed comb, and setting all my
 design-time and run-time properties, etc., as in those demos, I was able to
 get it to work.

Good :)
   
---
Rgds, Wilfried [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html
http://www.mestdagh.biz

-- 
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] Which TWSocketServer event to capture data sent?

2006-11-21 Thread Clay Shannon
 Maybe a typo error ?

No, all that code was copied-and-pasted from TCPSrv1.pas.

--The 10048 problem seemed to stem from some redundant code:

procedure TfClientMain.FormShow(Sender: TObject);
begin
  ApplicationEvents.OnException := ApplicationEventsException;

  if WSocketServer.Addr  '0.0.0.0' then begin
WSocketServer.Addr := '0.0.0.0'; { Use any interface  }
WSocketServer.Listen;{ Start listening for client }
  end;
  PostMessage(Handle, WM_APPSTARTUP, 0, 0);
end;

procedure TfClientMain.WMAppStartup(var Msg: TMessage);
begin
  WSocketServer.Proto   := 'tcp'; { Use TCP protocol  }
  WSocketServer.Port:= '1234';{ Use telnet port -- changed
to 1234 }
  WSocketServer.Addr:= '0.0.0.0'; { Use any interface }
  WSocketServer.ClientClass := TTcpSrvClient; { Use our component }
  WSocketServer.Listen;   { Start listening}
end;

Once I commented out much of the above code, the 10048 error went away (Addr
and Port are assigned in the .DFM):

procedure TfClientMain.FormShow(Sender: TObject);
begin
  ApplicationEvents.OnException := ApplicationEventsException;

//  if WSocketServer.Addr  '0.0.0.0' then begin
//WSocketServer.Addr := '0.0.0.0'; { Use any interface  }
//WSocketServer.Listen;{ Start listening for client }
//  end;
  PostMessage(Handle, WM_APPSTARTUP, 0, 0);
end;

procedure TfClientMain.WMAppStartup(var Msg: TMessage);
begin
  //WSocketServer.Proto   := 'tcp'; { Use TCP protocol  }
  //WSocketServer.Port:= '1234';{ Use telnet port -- changed
to 1234 }
  //WSocketServer.Addr:= '0.0.0.0'; { Use any interface }
  WSocketServer.ClientClass := TTcpSrvClient; { Use our component }
  WSocketServer.Listen;   { Start listening}
end;

The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material.  If the reader of this message is not the intended recipient,
you are hereby notified that your access is unauthorized, and any review,
dissemination, distribution or copying of this message including any
attachments is strictly prohibited.   If you are not the intended
recipient, please contact the sender and delete the material from any
computer.
-- 
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] Still rassling with sending and receiving

2006-11-21 Thread Clay Shannon
OK, by going over the clidemo and TCPServ projects (which successfully
communicate with each other) with a fine-toothed comb, and setting all my
design-time and run-time properties, etc., as in those demos, I was able to
get it to work.

Bravo! Salud! Hallelujah! Etc.

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Clay Shannon
Sent: Tuesday, November 21, 2006 9:55 AM
To: 'ICS support mailing'
Subject: [twsocket] Still rassling with sending and receiving

When I send a string from my test utility, the ClientConnect() event(*)
fires in my app, which is listening for messages, but the
ClientDataAvailable() event(**) is not fired. 

 

And when I send the message a second time from the test utility, I get
Connect: socket already in use.

 

Also, the sending utility freezes up after sending the message.

 

{ Taken from the ICS demo }

procedure TfClientMain.WSocketServerClientConnect(Sender: TObject; Client:
TWSocketClient; Error: Word);

begin

  with Client as TTcpSrvClient do begin

ShowMessage('Client connected.' +

' Remote: ' + PeerAddr + '/' + PeerPort +

' Local: '  + GetXAddr + '/' + GetXPort);

ShowMessage('There is now ' +

IntToStr(TWSocketServer(Sender).ClientCount) +

' client(s) connected.');

LineMode:= TRUE;

LineEdit:= TRUE;

LineLimit   := 255; { Do not accept long lines } //changed from
255

OnDataAvailable := ClientDataAvailable;

OnLineLimitExceeded := ClientLineLimitExceeded;

OnBgException   := ClientBgException;

ConnectTime := Now;

  end;

end;

 

{ Taken from the ICS demo, too -- this event never gets fired }

procedure TfClientMain.ClientDataAvailable(Sender: TObject; Error: Word);

begin

  with Sender as TTcpSrvClient do begin

{ We use line mode. We will receive complete lines }

RcvdLine := ReceiveStr;

{ Remove trailing CR/LF }

while (Length(RcvdLine)  0) and

  (RcvdLine[Length(RcvdLine)] in [#13, #10]) do

  RcvdLine := Copy(RcvdLine, 1, Length(RcvdLine) - 1);

ShowMessage('Received from ' + GetPeerAddr + ': ''' + RcvdLine + );

//ProcessData(Sender as TTcpSrvClient);

  end;

end;

 

I must be missing something yet...


The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material.  If the reader of this message is not the intended recipient,
you are hereby notified that your access is unauthorized, and any review,
dissemination, distribution or copying of this message including any
attachments is strictly prohibited.   If you are not the intended
recipient, please contact the sender and delete the material from any
computer.
-- 
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] TWSocket sync send problem within ISAPI

2006-11-21 Thread Francois PIETTE
 Thanks for the pointer. The error is 10035.

As you can see in the docs, it is WSAEWOULDBLOCK. This not a real error in a 
non-blocking environment. It just mean the winsock call would block to 
execute the task and non-blocking mode has been selected.

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


[twsocket] Local UDP Broadcast without network cable connected

2006-11-21 Thread KL Chin
Hi,

How can I used a PC without network cable connected (WinXP), to
do broadcast with UDP. i.e.

Create 1 Send socket with 
  Send.Addr= '255.255.255.255'
  Send.LocalAddr   = '127.0.0.1'
  Send.ReuseAddr   = true

And few Listen socket
  Listen.Addr  = '0.0.0.0'   
  Listen.LocalAddr = '127.0.0.1'
  Listen.ReuseAddr = true

If the PC connected with cable, both LocalAddr I set
to x.x.x.x, and it work well.

What others setting I needed to set, in order to work
when cable not connect?

Regards,
KL Chin




-- 
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] Connect, send and close

2006-11-21 Thread Engi
Hi,

I need a client function that connects to server, send data and close 
connection.

My code is :

bool __fastcall TfrmMain::SendCde(int PortIP, AnsiString Cde)
{
 bool Result;
 int Sent;

 WSocket-LineMode = true;
 WSocket-LineEnd = \r\n;
 WSocket-Proto  = tcp;
 WSocket-Port  = PortIP;
 WSocket-Addr  = AdrIP;

 WSocket-Connect();

try
 {
  Sent = WSocket-SendStr(Cde + \r\n);
  Result = (Sent == Cde.Length());
 }
 else
 {
  Result = false;
 }

 if ((WSocket-State == wsConnected) || (WSocket-State == wsConnecting)) 
WSocket-Close();
 return Result;
}


Here, the result is false everytimes because the socket is never connected.
How could I do this function works ?

Thanks for help,
Engi 

-- 
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] Connect, send and close

2006-11-21 Thread Engi
A little error in my code.
I repost it

- Original Message - 
From: Engi [EMAIL PROTECTED]
To: ICS support mailing twsocket@elists.org
Sent: Wednesday, November 22, 2006 8:24 AM
Subject: [twsocket] Connect, send and close


 bool __fastcall TfrmMain::SendCde(int PortIP, AnsiString Cde)
{
bool Result;
int Sent;

WSocket-LineMode = true;
WSocket-LineEnd = \r\n;
WSocket-Proto  = tcp;
WSocket-Port  = PortIP;
WSocket-Addr  = AdrIP;

WSocket-Connect();

if
{
Sent = WSocket-SendStr(Cde + \r\n);
Result = (Sent == Cde.Length());
}
else
{
Result = false;
}

if ((WSocket-State == wsConnected) || (WSocket-State == wsConnecting))
WSocket-Close();

return Result;
}


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