Re: [twsocket] Which TWSocketServer event to capture data sent?
<< 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] Which TWSocketServer event to capture data sent?
> 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] 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
[twsocket] Which TWSocketServer event to capture data sent?
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] Which TWSocketServer event to capture data sent?
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?
> << 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] 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
Re: [twsocket] Which TWSocketServer event to capture data sent?
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] Which TWSocketServer event to capture data sent?
> 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] Which TWSocketServer event to capture data sent?
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] Which TWSocketServer event to capture data sent?
<<> Why would I get EInvalidCast when TcpSrv doesn't, although the cast and the > custom class are the same? Maybe a typo error ?>> No, all that code was copied-and-pasted from TCPSrv1.pas. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Francois Piette Sent: Tuesday, November 21, 2006 1:52 AM 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. 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 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