Re: [twsocket] Telnet Client
> See any other obvious issues? Any problem calling Free > immediately after Close in FreeTelnetClient? Probably. ICS is asynchronous. It means methods are just request to do some operation: the operation is started, you get control back immediately while the request is executed in the background. Programming sequentially with that behaviour is problematic. You should use the events to do the next operation when the previous one is done. See the FAQ on the wiki. There is an article about async programming. -- francois.pie...@overbyte.be The author of the freeware multi-tier middleware MidWare The author of the freeware Internet Component Suite (ICS) http://www.overbyte.be - Original Message - From: "Mike Lenox" To: "ICS support mailing" Sent: Friday, May 01, 2009 12:44 PM Subject: [twsocket] Telnet Client > More info concerning my original problem which is ... > > My application uses a TTnCnx client object to connect (hundreds of times > per day) to a remote device to retrieve data. On rare occasions the pair > seem to get stuck in a connected state and stay there indefinitely. > > The normal procedure is to call SendMsg which calls Connect. > OnConnection, write the outgoing message. When a response is received, > call ClosePort. If no response, MsgTimeout. > > {As I write this I see one problem, I don't call Close in the timeout > procedure. Yet, after several failures, I would still call > NewTelnetClient which I would expect to get me out of the hung state} > > See any other obvious issues? Any problem calling Free immediately after > Close in FreeTelnetClient? > > Mike > > > > > > > procedure TTLS350E.SendMsg(Msg: string); > begin > try >if assigned(TelnetClient) then > begin > TxTCPBuffer := Msg; > if TelnetClient.IsConnected = True then begin { connection is > already active } >WriteToTelnet(Msg); > end else begin { got to get a connection } >TelnetClient.Connect; > end; >end; > except >ShowNewMessage( 'Exception handled in TCP SendMsg'); > end; > end; > > procedure TTLS350E.ClosePort; > begin > TelnetClient.Close; > end; > > procedure TTLS350E.MsgTimeout(Sender: TObject); > begin > inc(PortRebuildCount); > if PortRebuildCount >= TLS350_TIMEOUTS_RESET then begin >PortRebuildCount := 0; >NewTelnetClient; > end; > end; > > procedure TTLS350E.FreePort; // This should only be called from > Destroy > begin > FreeTelnetClient; > end; > > procedure TTLS350E.FreeTelnetClient; > var > tmpTelnet: TTnCnx; > begin > if assigned(TelnetClient) then begin// if TCP client exists, kill it >tmpTelnet := TelnetClient; >tmpTelnet.Close; >tmpTelnet.Free; >TelnetClient := nil; > end; > end; > > // The following function is called only after multiple > // message failures. > // build a new Telnet object > procedure TTLS350E.NewTelnetClient; > begin > FreeTelnetClient; > TelnetClient := TTnCnx.Create(Application.MainForm); > TelnetClient.OnDataAvailable := TnCnxDataAvailable; > TelnetClient.OnSessionClosed := TnCnxSessionClosed; > TelnetClient.OnSessionConnected := TnCnxSessionConnected; > TelnetClient.Port := IntToStr(MyConfig.GetPort); > TelnetClient.Host := MyConfig.GetIP; > end; > > -- > To unsubscribe or change your settings for TWSocket mailing list > please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket > Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
[twsocket] Telnet Client
More info concerning my original problem which is ... My application uses a TTnCnx client object to connect (hundreds of times per day) to a remote device to retrieve data. On rare occasions the pair seem to get stuck in a connected state and stay there indefinitely. The normal procedure is to call SendMsg which calls Connect. OnConnection, write the outgoing message. When a response is received, call ClosePort. If no response, MsgTimeout. {As I write this I see one problem, I don't call Close in the timeout procedure. Yet, after several failures, I would still call NewTelnetClient which I would expect to get me out of the hung state} See any other obvious issues? Any problem calling Free immediately after Close in FreeTelnetClient? Mike procedure TTLS350E.SendMsg(Msg: string); begin try if assigned(TelnetClient) then begin TxTCPBuffer := Msg; if TelnetClient.IsConnected = True then begin { connection is already active } WriteToTelnet(Msg); end else begin { got to get a connection } TelnetClient.Connect; end; end; except ShowNewMessage( 'Exception handled in TCP SendMsg'); end; end; procedure TTLS350E.ClosePort; begin TelnetClient.Close; end; procedure TTLS350E.MsgTimeout(Sender: TObject); begin inc(PortRebuildCount); if PortRebuildCount >= TLS350_TIMEOUTS_RESET then begin PortRebuildCount := 0; NewTelnetClient; end; end; procedure TTLS350E.FreePort; // This should only be called from Destroy begin FreeTelnetClient; end; procedure TTLS350E.FreeTelnetClient; var tmpTelnet: TTnCnx; begin if assigned(TelnetClient) then begin// if TCP client exists, kill it tmpTelnet := TelnetClient; tmpTelnet.Close; tmpTelnet.Free; TelnetClient := nil; end; end; // The following function is called only after multiple // message failures. // build a new Telnet object procedure TTLS350E.NewTelnetClient; begin FreeTelnetClient; TelnetClient := TTnCnx.Create(Application.MainForm); TelnetClient.OnDataAvailable := TnCnxDataAvailable; TelnetClient.OnSessionClosed := TnCnxSessionClosed; TelnetClient.OnSessionConnected := TnCnxSessionConnected; TelnetClient.Port := IntToStr(MyConfig.GetPort); TelnetClient.Host := MyConfig.GetIP; end; -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Telnet problems
> I already looked at TnScript 2-3 minutes, but I think this only works if > the Telnet session is designed like this: > > Step 1 - Step 2 - Step 3... so each step is a screen completely > different from each other. TTnScript associate events to strings detected in the data flow no matter how it is organized in "screens". You can add/remove events dynamically if you have complex things to do. > My session will more look like this: > > Step 1 (Screen 1) - Step 2 (Screen 2) - Step 3 (Screen 1 again) etc. so > the same screen will come again and again. > > And I can't guarantee that the last line is always the same for these > screens, because the vendor of the device to be configured could enhance > the configuration... There is no guarantee. It is only dependent on the way the device vendor organized his program. > Do you have a short example of this (for my special case)? I have no example for any case :-( I wrote that code to automate a specific application I had to write. And as usual I've put that code in a reusable component. The only doc I have is what you can see in the comments in the source file. > Or some explanaitions on OnDataAvailable, Data has been received. > OnLocalEcho, the properties LocalEcho That is telnet protocol options negociation. Using telnet (as with an old RS232 terminal), when a user type on the keyboard, the character is either immediately shown on screen (local echo on) and sent to the remote host, or (local echo off) only sent to the remote host which will echo it back to the user screen. > and Backlog? The component handle terminal emulation with the screen higher than actual screen. For example, the host think it has a 80x25 screen while the component keep characters which have scrolled out of the screen. -- Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html -- [EMAIL PROTECTED] http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Telnet problems
> Francois replied: > > I think TTnScript is the way to go. You can dynamically add/remove events > according to which "screen" you detect. If you don't use TTnScript, has a > look at his source code to understand how to get hand on the input stream to > chack for data. > > I also uploaded a modified version of the components. It is a proposal of > changes by John Porteous. It will probably appear shortly in the > distribution. You may try it: > http://www.overbyte.be/arch/dump/EmulVTJohnPorteous.zip > > Hello, I already looked at TnScript 2-3 minutes, but I think this only works if the Telnet session is designed like this: Step 1 - Step 2 - Step 3... so each step is a screen completely different from each other. My session will more look like this: Step 1 (Screen 1) - Step 2 (Screen 2) - Step 3 (Screen 1 again) etc. so the same screen will come again and again. Do you have a short example of this (for my special case)? And I can't guarantee that the last line is always the same for these screens, because the vendor of the device to be configured could enhance the configuration... Or some explanaitions on OnDataAvailable, OnLocalEcho, the properties LocalEcho and Backlog? And in my app. I see that the telnet session is messed up, means part of the screen which should be displayed top is "delayed" and thus displayed at the bottom rather. I think it comes from sending the next command to fast (when not yet all data has been received from the old one) so it messes up. One idea of mine is to send the first command, wait for the first OnDataAvailable and then do a sort of busy wait or similar until a certain period is over so that delayed OnDataAvailables for the same screen can pass and then send the next command. Is this feasible? Otherwise I'd use a TnCNX if the TnScript based method doesn't work. Greetings Markus -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Telnet problems
I think TTnScript is the way to go. You can dynamically add/remove events according to which "screen" you detect. If you don't use TTnScript, has a look at his source code to understand how to get hand on the input stream to chack for data. I also uploaded a modified version of the components. It is a proposal of changes by John Porteous. It will probably appear shortly in the distribution. You may try it: http://www.overbyte.be/arch/dump/EmulVTJohnPorteous.zip 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: "Humm, Markus" <[EMAIL PROTECTED]> To: Sent: Friday, November 17, 2006 11:46 AM Subject: [twsocket] Telnet problems > Hello, > > I've some big problems with the telnet components, the biggest one being > the lack of documentation. > > What I want to do is the following: > > 1. start a telnet session (that one works) > > 2. have a list of commands > > 3. loop through the list and carry out one command after the other > > 4. display the telnet output in some window, scrollable so that I can > see the history to verify it. > > What I'm doing right now is: > > 1. start a telnet connection > > 2. wait until isconnected becomes true or 2 sec. Timeout >(the telnetserver is the only node on a local lan so it's fast and > works reliably) > > 3. In the OnDataAvailable I do this: > >if endofcommands = false then >begin > TnEmulVT.SendStr(nextcommandstring); >end; > >Where commandstring will be sometings like '2'+#13 or 'mytext'+#13 or > ''+#13. > > 4. the device on the other side is menu based where each menu item has a > number unique to that menu level. > >e.g. the main menu might look like this: > >1. first submenu >2. second submenu > >If I go to 2nd submenu another menu is displayed: > >1. do something >2. do something other >3. set testtext > >If I go to the 2nd submenu and select the 3. item I get a prompt: > >enter your text: > >After this prompt I want to enter text and if it is terminated by #13 >I get the 2nd submenu displayed again, (seems normal) where I can get > up to the main menu by just sending #13. > >I get to the "set testtext" menu already and the prompt is displayed, > but my text sent is not entered as it seems. >I've a breakpoint in nDataAvailable but it is only reached twice, so > the call of that menu works but the text >isn't enered because it's nerver being sent due to OnDataAvailabe not > being raised. LocalEcho is off. >My program simply displays the terminal then and when I enter some > chars they're always shown twice in the terminal. >Why is this? > >I tried OnLocalEcho as well but I think the results where even worse, > I think it only occured once and then stopped. >What good is OnEndOfRecord for besides? > >I think I can't use TnScript, because the same menu items will be > displayed several times because I have >to "traverse" the submenus several times. > > Scrolling back also messes up the whole TnEmulVT as well as changing the > font size and lineheight > (the cursor is between the lines then). So this would be a enhancement > request ( ;-) ) to properly support these things. > > Greetings > > Markus > -- > To unsubscribe or change your settings for TWSocket mailing list > please goto http://www.elists.org/mailman/listinfo/twsocket > Visit our website at http://www.overbyte.be -- 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] Telnet problems
Hello, I've some big problems with the telnet components, the biggest one being the lack of documentation. What I want to do is the following: 1. start a telnet session (that one works) 2. have a list of commands 3. loop through the list and carry out one command after the other 4. display the telnet output in some window, scrollable so that I can see the history to verify it. What I'm doing right now is: 1. start a telnet connection 2. wait until isconnected becomes true or 2 sec. Timeout (the telnetserver is the only node on a local lan so it's fast and works reliably) 3. In the OnDataAvailable I do this: if endofcommands = false then begin TnEmulVT.SendStr(nextcommandstring); end; Where commandstring will be sometings like '2'+#13 or 'mytext'+#13 or ''+#13. 4. the device on the other side is menu based where each menu item has a number unique to that menu level. e.g. the main menu might look like this: 1. first submenu 2. second submenu If I go to 2nd submenu another menu is displayed: 1. do something 2. do something other 3. set testtext If I go to the 2nd submenu and select the 3. item I get a prompt: enter your text: After this prompt I want to enter text and if it is terminated by #13 I get the 2nd submenu displayed again, (seems normal) where I can get up to the main menu by just sending #13. I get to the "set testtext" menu already and the prompt is displayed, but my text sent is not entered as it seems. I've a breakpoint in nDataAvailable but it is only reached twice, so the call of that menu works but the text isn't enered because it's nerver being sent due to OnDataAvailabe not being raised. LocalEcho is off. My program simply displays the terminal then and when I enter some chars they're always shown twice in the terminal. Why is this? I tried OnLocalEcho as well but I think the results where even worse, I think it only occured once and then stopped. What good is OnEndOfRecord for besides? I think I can't use TnScript, because the same menu items will be displayed several times because I have to "traverse" the submenus several times. Scrolling back also messes up the whole TnEmulVT as well as changing the font size and lineheight (the cursor is between the lines then). So this would be a enhancement request ( ;-) ) to properly support these things. Greetings Markus -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Telnet, Ping and ARP
> I'm looking for good ways to write a device configuration program using > ICS. The devices to be configured can be configured via Telnet and the > IP can be assigned via creating some arp entry for it and the first > packet sent to the device sets its address. > > What I'd like to do is: > > - set the device address via ARP and then ping the device to > check whether the address is set correctly. At least on my home pc I > didn't find the ping component...strange. How does it work anyway? ICS has a TPing component installed by default. It is in ping.pas source file. > - then I'd like to have some sort of array which contains all necessary > telnet configuration steps, because if something changes in the device > I can change my program more flexible/faster. Which telnet component > to use? I don't want to show the user the telnet output but might want > to have a debug tab or so for me showing it if anything breaks or > during development. How to achieve it? The base component handling the telnet protocol is TTnCnx. TTnCnx has no user interface at all. Then you have TTnEmulVT which add ansi/vt100 screen emulation and then you have TTnScript which is TTnEmultVT with some facilities to automate things like login and others. TTnEmulVT and TTnScrpti can have their window located on some TTabSheet which is not displayed except when needed. I wrote a multisession terminal like that: a TPageControl has one TTabSheet per session. The user see only one at a time (or none at all) and this doesn't prevent the invisible telnet sessions to be up and running. > Unfortunatelly it's not yet documented in the Wiki, I thought to give it > a start lately by entering the properties of the telnet connection > component, but obviously it didn't start anybody else on that... Have a look at TnClient sample program. It is a very basic telnet client with ansi/vt100. Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html -- [EMAIL PROTECTED] The author for the freeware multi-tier middleware MidWare The author of the freeware Internet Component Suite (ICS) http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
[twsocket] Telnet, Ping and ARP
Hello, I'm looking for good ways to write a device configuration program using ICS. The devices to be configured can be configured via Telnet and the IP can be assigned via creating some arp entry for it and the first packet sent to the device sets its address. What I'd like to do is: - set the device address via ARP and then ping the device to check whether the address is set correctly. At least on my home pc I didn't find the ping component...strange. How does it work anyway? - then I'd like to have some sort of array which contains all necessary telnet configuration steps, because if something changes in the device I can change my program more flexible/faster. Which telnet component to use? I don't want to show the user the telnet output but might want to have a debug tab or so for me showing it if anything breaks or during development. How to achieve it? Unfortunatelly it's not yet documented in the Wiki, I thought to give it a start lately by entering the properties of the telnet connection component, but obviously it didn't start anybody else on that... Greetings Markus -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Telnet
Ok, no problem, but I send a email to you two hours earlier, in private, suggesting this... :) Arnoldo - Original Message - From: "Francois Piette" <[EMAIL PROTECTED]> To: "ICS support mailing" Sent: Wednesday, May 25, 2005 11:35 AM Subject: Re: [twsocket] Telnet About redirect connection, in my small project this worked well ! It would be interesting to publish your small project on the usermade page at ICS website. -- [EMAIL PROTECTED] Author of ICS (Internet Component Suite, freeware) Author of MidWare (Multi-tier framework, freeware) http://www.overbyte.be - Original Message - From: "Arnoldo - Optextil" <[EMAIL PROTECTED]> To: "ICS support mailing" Sent: Wednesday, May 25, 2005 3:10 PM Subject: Re: [twsocket] Telnet Hi, About redirect connection, in my small project this worked well ! Thanks François and another members of ICS list. Arnoldo - Original Message - From: "Francois PIETTE" <[EMAIL PROTECTED]> To: "ICS support mailing" Sent: Tuesday, May 24, 2005 1:51 PM Subject: Re: [twsocket] Telnet >I have found this article explainign how to inherit from a socket >handle: > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/shared_sockets_2.asp > > -- > [EMAIL PROTECTED] > http://www.overbyte.be > > - Original Message - > From: "Francois Piette" <[EMAIL PROTECTED]> > To: "ICS support mailing" > Sent: Tuesday, May 24, 2005 4:33 PM > Subject: Re: [twsocket] Telnet > > >> > ShellExecute(Application.Handle, 'open', @ClientFileName, > @ClientParams, >> > @ClientDir, SW_SHOW); >> >> I'm not sure you can use ShellExecute to inherit handles. Use > CreateProcess which has a parameter >> bInheritHandles. >> >> > to server with "telnet 127.0.0.1 5000"... The client project is > executed, >> > but show message "10038". >> >> Error 10038 means you pass a handle to winsock that is not a socket > handle. In your case, the handle >> is not inherited from the parent process. >> >> -- >> [EMAIL PROTECTED] >> http://www.overbyte.be >> >> >> - Original Message - >> From: "Arnoldo - Optextil" <[EMAIL PROTECTED]> >> To: "ICS support mailing" >> Sent: Tuesday, May 24, 2005 3:23 PM >> Subject: Re: [twsocket] Telnet >> >> >> > Hi, >> > >> > About redirect the connection, I created two small projects, >> > exemplify > the >> > problem ! >> > >> > Server: >> > >> > unit UServer; >> > >> > interface >> > >> > uses >> > Windows, Messages, SysUtils, Variants, Classes, Graphics, >> > Controls, > Forms, >> > Dialogs, WSocket, SHELLAPI; >> > >> > type >> > TForm1 = class(TForm) >> > SrvSocket: TWSocket; >> > procedure FormCreate(Sender: TObject); >> > procedure SrvSocketSessionAvailable(Sender: TObject; ErrCode: >> > Word); >> > private >> > { Private declarations } >> > public >> > { Public declarations } >> > end; >> > >> > var >> > Form1: TForm1; >> > >> > implementation >> > >> > {$R *.dfm} >> > >> > procedure TForm1.FormCreate(Sender: TObject); >> > begin >> > SrvSocket.Close; >> > SrvSocket.Addr := '0.0.0.0'; { Use any interface for listening } >> > SrvSocket.Proto := 'tcp'; >> > SrvSocket.Port := '5000'; >> > SrvSocket.Listen; >> > end; >> > >> > procedure TForm1.SrvSocketSessionAvailable(Sender: TObject; ErrCode: > Word); >> > var >> > ClientFileName, ClientParams, ClientDir : array [0..255] of char; >> > NewHSocket : TSocket; >> > begin >> > NewHSocket := SrvSocket.Accept; >> > StrPCopy(@ClientFileName, 'c:\rf\projectcliente.exe'); >> > StrPCopy(@ClientParams, ''+ inttostr(newhsocket)); >> > StrPCopy(@ClientDir, 'c:\rf\'); >> > ShellExecute(Application.Handle, 'open', @ClientFileName, > @ClientParams, >> > @ClientDir, SW_SHOW); >> > end; >> > >> > Client: >> > >> > unit UCliente; >> > >> > interface >> > >> > uses >> > Windows, Messages, SysUtils, Variants, Classes, Graphics, >> > Controls, > F
Re: [twsocket] Telnet
> About redirect connection, in my small project this worked well ! It would be interesting to publish your small project on the usermade page at ICS website. -- [EMAIL PROTECTED] Author of ICS (Internet Component Suite, freeware) Author of MidWare (Multi-tier framework, freeware) http://www.overbyte.be - Original Message - From: "Arnoldo - Optextil" <[EMAIL PROTECTED]> To: "ICS support mailing" Sent: Wednesday, May 25, 2005 3:10 PM Subject: Re: [twsocket] Telnet > Hi, > > About redirect connection, in my small project this worked well ! > > Thanks François and another members of ICS list. > > Arnoldo > > - Original Message - > From: "Francois PIETTE" <[EMAIL PROTECTED]> > To: "ICS support mailing" > Sent: Tuesday, May 24, 2005 1:51 PM > Subject: Re: [twsocket] Telnet > > > >I have found this article explainign how to inherit from a socket handle: > > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/shared_sockets_2.asp > > > > -- > > [EMAIL PROTECTED] > > http://www.overbyte.be > > > > - Original Message - > > From: "Francois Piette" <[EMAIL PROTECTED]> > > To: "ICS support mailing" > > Sent: Tuesday, May 24, 2005 4:33 PM > > Subject: Re: [twsocket] Telnet > > > > > >> > ShellExecute(Application.Handle, 'open', @ClientFileName, > > @ClientParams, > >> > @ClientDir, SW_SHOW); > >> > >> I'm not sure you can use ShellExecute to inherit handles. Use > > CreateProcess which has a parameter > >> bInheritHandles. > >> > >> > to server with "telnet 127.0.0.1 5000"... The client project is > > executed, > >> > but show message "10038". > >> > >> Error 10038 means you pass a handle to winsock that is not a socket > > handle. In your case, the handle > >> is not inherited from the parent process. > >> > >> -- > >> [EMAIL PROTECTED] > >> http://www.overbyte.be > >> > >> > >> - Original Message - > >> From: "Arnoldo - Optextil" <[EMAIL PROTECTED]> > >> To: "ICS support mailing" > >> Sent: Tuesday, May 24, 2005 3:23 PM > >> Subject: Re: [twsocket] Telnet > >> > >> > >> > Hi, > >> > > >> > About redirect the connection, I created two small projects, exemplify > > the > >> > problem ! > >> > > >> > Server: > >> > > >> > unit UServer; > >> > > >> > interface > >> > > >> > uses > >> > Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, > > Forms, > >> > Dialogs, WSocket, SHELLAPI; > >> > > >> > type > >> > TForm1 = class(TForm) > >> > SrvSocket: TWSocket; > >> > procedure FormCreate(Sender: TObject); > >> > procedure SrvSocketSessionAvailable(Sender: TObject; ErrCode: > >> > Word); > >> > private > >> > { Private declarations } > >> > public > >> > { Public declarations } > >> > end; > >> > > >> > var > >> > Form1: TForm1; > >> > > >> > implementation > >> > > >> > {$R *.dfm} > >> > > >> > procedure TForm1.FormCreate(Sender: TObject); > >> > begin > >> > SrvSocket.Close; > >> > SrvSocket.Addr := '0.0.0.0'; { Use any interface for listening } > >> > SrvSocket.Proto := 'tcp'; > >> > SrvSocket.Port := '5000'; > >> > SrvSocket.Listen; > >> > end; > >> > > >> > procedure TForm1.SrvSocketSessionAvailable(Sender: TObject; ErrCode: > > Word); > >> > var > >> > ClientFileName, ClientParams, ClientDir : array [0..255] of char; > >> > NewHSocket : TSocket; > >> > begin > >> > NewHSocket := SrvSocket.Accept; > >> > StrPCopy(@ClientFileName, 'c:\rf\projectcliente.exe'); > >> > StrPCopy(@ClientParams, ''+ inttostr(newhsocket)); > >> > StrPCopy(@ClientDir, 'c:\rf\'); > >> > ShellExecute(Application.Handle, 'open', @ClientFileName, > > @ClientParams, > >> > @ClientDir, SW_SHOW); > >> > end; > >> > > &
Re: [twsocket] Telnet
Hi, About redirect connection, in my small project this worked well ! Thanks François and another members of ICS list. Arnoldo - Original Message - From: "Francois PIETTE" <[EMAIL PROTECTED]> To: "ICS support mailing" Sent: Tuesday, May 24, 2005 1:51 PM Subject: Re: [twsocket] Telnet I have found this article explainign how to inherit from a socket handle: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/shared_sockets_2.asp -- [EMAIL PROTECTED] http://www.overbyte.be - Original Message - From: "Francois Piette" <[EMAIL PROTECTED]> To: "ICS support mailing" Sent: Tuesday, May 24, 2005 4:33 PM Subject: Re: [twsocket] Telnet > ShellExecute(Application.Handle, 'open', @ClientFileName, @ClientParams, > @ClientDir, SW_SHOW); I'm not sure you can use ShellExecute to inherit handles. Use CreateProcess which has a parameter bInheritHandles. > to server with "telnet 127.0.0.1 5000"... The client project is executed, > but show message "10038". Error 10038 means you pass a handle to winsock that is not a socket handle. In your case, the handle is not inherited from the parent process. -- [EMAIL PROTECTED] http://www.overbyte.be - Original Message - From: "Arnoldo - Optextil" <[EMAIL PROTECTED]> To: "ICS support mailing" Sent: Tuesday, May 24, 2005 3:23 PM Subject: Re: [twsocket] Telnet > Hi, > > About redirect the connection, I created two small projects, exemplify the > problem ! > > Server: > > unit UServer; > > interface > > uses > Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, > Dialogs, WSocket, SHELLAPI; > > type > TForm1 = class(TForm) > SrvSocket: TWSocket; > procedure FormCreate(Sender: TObject); > procedure SrvSocketSessionAvailable(Sender: TObject; ErrCode: > Word); > private > { Private declarations } > public > { Public declarations } > end; > > var > Form1: TForm1; > > implementation > > {$R *.dfm} > > procedure TForm1.FormCreate(Sender: TObject); > begin > SrvSocket.Close; > SrvSocket.Addr := '0.0.0.0'; { Use any interface for listening } > SrvSocket.Proto := 'tcp'; > SrvSocket.Port := '5000'; > SrvSocket.Listen; > end; > > procedure TForm1.SrvSocketSessionAvailable(Sender: TObject; ErrCode: Word); > var > ClientFileName, ClientParams, ClientDir : array [0..255] of char; > NewHSocket : TSocket; > begin > NewHSocket := SrvSocket.Accept; > StrPCopy(@ClientFileName, 'c:\rf\projectcliente.exe'); > StrPCopy(@ClientParams, ''+ inttostr(newhsocket)); > StrPCopy(@ClientDir, 'c:\rf\'); > ShellExecute(Application.Handle, 'open', @ClientFileName, @ClientParams, > @ClientDir, SW_SHOW); > end; > > Client: > > unit UCliente; > > interface > > uses > Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, > Dialogs, WSocket, Spin, StdCtrls, Buttons, WinSock; > > type > TForm2 = class(TForm) > Socket: TWSocket; > Memo: TMemo; > procedure SocketDataAvailable(Sender: TObject; ErrCode: Word); > procedure FormCreate(Sender: TObject); > private > { Private declarations } > public > { Public declarations } > end; > > var > Form2: TForm2; > > implementation > > {$R *.dfm} > > procedure TForm2.SocketDataAvailable(Sender: TObject; ErrCode: Word); > var > Buffer : array [0..1023] of char; > Len : Integer; > begin > Len := Socket.Receive(@Buffer, SizeOf(Buffer) - 1); > if Len <= 0 then > Exit; > > Buffer[Len] := #0; > Memo.lines.add(StrPas(Buffer)); > end; > > procedure TForm2.FormCreate(Sender: TObject); > var > NewHSocket : TSocket; > begin > if paramcount = 1 then > Begin > caption := ParamStr(1); > NewHSocket := StrToIntDef(ParamStr(1),0); > Socket.Dup(NewHSocket); > End; > end; > > Running this example, the server is listen on port 5000, on prompt I connect > to server with "telnet 127.0.0.1 5000"... The client project is executed, > but > show message "10038". > > When you say: "Once you have the > socket handle for the accepted connection, you may start another process, > make it inherit the handle and let him process the connection. The second > process may use TWSocket and receive the inherited handle using Dup(). > " > > The implementation above is correct ? If not, have a sample ? > > Thanks > >
Re: [twsocket] Telnet
I have found this article explainign how to inherit from a socket handle: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/shared_sockets_2.asp -- [EMAIL PROTECTED] http://www.overbyte.be - Original Message - From: "Francois Piette" <[EMAIL PROTECTED]> To: "ICS support mailing" Sent: Tuesday, May 24, 2005 4:33 PM Subject: Re: [twsocket] Telnet > > ShellExecute(Application.Handle, 'open', @ClientFileName, @ClientParams, > > @ClientDir, SW_SHOW); > > I'm not sure you can use ShellExecute to inherit handles. Use CreateProcess which has a parameter > bInheritHandles. > > > to server with "telnet 127.0.0.1 5000"... The client project is executed, > > but show message "10038". > > Error 10038 means you pass a handle to winsock that is not a socket handle. In your case, the handle > is not inherited from the parent process. > > -- > [EMAIL PROTECTED] > http://www.overbyte.be > > > - Original Message - > From: "Arnoldo - Optextil" <[EMAIL PROTECTED]> > To: "ICS support mailing" > Sent: Tuesday, May 24, 2005 3:23 PM > Subject: Re: [twsocket] Telnet > > > > Hi, > > > > About redirect the connection, I created two small projects, exemplify the > > problem ! > > > > Server: > > > > unit UServer; > > > > interface > > > > uses > > Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, > > Dialogs, WSocket, SHELLAPI; > > > > type > > TForm1 = class(TForm) > > SrvSocket: TWSocket; > > procedure FormCreate(Sender: TObject); > > procedure SrvSocketSessionAvailable(Sender: TObject; ErrCode: Word); > > private > > { Private declarations } > > public > > { Public declarations } > > end; > > > > var > > Form1: TForm1; > > > > implementation > > > > {$R *.dfm} > > > > procedure TForm1.FormCreate(Sender: TObject); > > begin > > SrvSocket.Close; > > SrvSocket.Addr := '0.0.0.0'; { Use any interface for listening } > > SrvSocket.Proto := 'tcp'; > > SrvSocket.Port := '5000'; > > SrvSocket.Listen; > > end; > > > > procedure TForm1.SrvSocketSessionAvailable(Sender: TObject; ErrCode: Word); > > var > > ClientFileName, ClientParams, ClientDir : array [0..255] of char; > > NewHSocket : TSocket; > > begin > > NewHSocket := SrvSocket.Accept; > > StrPCopy(@ClientFileName, 'c:\rf\projectcliente.exe'); > > StrPCopy(@ClientParams, ''+ inttostr(newhsocket)); > > StrPCopy(@ClientDir, 'c:\rf\'); > > ShellExecute(Application.Handle, 'open', @ClientFileName, @ClientParams, > > @ClientDir, SW_SHOW); > > end; > > > > Client: > > > > unit UCliente; > > > > interface > > > > uses > > Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, > > Dialogs, WSocket, Spin, StdCtrls, Buttons, WinSock; > > > > type > > TForm2 = class(TForm) > > Socket: TWSocket; > > Memo: TMemo; > > procedure SocketDataAvailable(Sender: TObject; ErrCode: Word); > > procedure FormCreate(Sender: TObject); > > private > > { Private declarations } > > public > > { Public declarations } > > end; > > > > var > > Form2: TForm2; > > > > implementation > > > > {$R *.dfm} > > > > procedure TForm2.SocketDataAvailable(Sender: TObject; ErrCode: Word); > > var > > Buffer : array [0..1023] of char; > > Len : Integer; > > begin > > Len := Socket.Receive(@Buffer, SizeOf(Buffer) - 1); > > if Len <= 0 then > > Exit; > > > > Buffer[Len] := #0; > > Memo.lines.add(StrPas(Buffer)); > > end; > > > > procedure TForm2.FormCreate(Sender: TObject); > > var > > NewHSocket : TSocket; > > begin > > if paramcount = 1 then > > Begin > > caption := ParamStr(1); > > NewHSocket := StrToIntDef(ParamStr(1),0); > > Socket.Dup(NewHSocket); > > End; > > end; > > > > Running this example, the server is listen on port 5000, on prompt I connect > > to server with "telnet 127.0.0.1 5000"... The client project is executed, > > but > > show message "10038". > > > > When you say: "Once you have the > > socket h
Re: [twsocket] Telnet
I think you will need to pass the handle as a stdin handle using CreateProcess, rather than just passing an integer on the command line. Otherwise, the handle will be specific to your server process and invalid in the client process. Dan - Original Message - From: "Arnoldo - Optextil" <[EMAIL PROTECTED]> To: "ICS support mailing" Sent: Tuesday, May 24, 2005 2:23 PM Subject: Re: [twsocket] Telnet Hi, About redirect the connection, I created two small projects, exemplify the problem ! Server: unit UServer; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, WSocket, SHELLAPI; type TForm1 = class(TForm) SrvSocket: TWSocket; procedure FormCreate(Sender: TObject); procedure SrvSocketSessionAvailable(Sender: TObject; ErrCode: Word); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); begin SrvSocket.Close; SrvSocket.Addr := '0.0.0.0'; { Use any interface for listening } SrvSocket.Proto := 'tcp'; SrvSocket.Port := '5000'; SrvSocket.Listen; end; procedure TForm1.SrvSocketSessionAvailable(Sender: TObject; ErrCode: Word); var ClientFileName, ClientParams, ClientDir : array [0..255] of char; NewHSocket : TSocket; begin NewHSocket := SrvSocket.Accept; StrPCopy(@ClientFileName, 'c:\rf\projectcliente.exe'); StrPCopy(@ClientParams, ''+ inttostr(newhsocket)); StrPCopy(@ClientDir, 'c:\rf\'); ShellExecute(Application.Handle, 'open', @ClientFileName, @ClientParams, @ClientDir, SW_SHOW); end; Client: unit UCliente; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, WSocket, Spin, StdCtrls, Buttons, WinSock; type TForm2 = class(TForm) Socket: TWSocket; Memo: TMemo; procedure SocketDataAvailable(Sender: TObject; ErrCode: Word); procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form2: TForm2; implementation {$R *.dfm} procedure TForm2.SocketDataAvailable(Sender: TObject; ErrCode: Word); var Buffer : array [0..1023] of char; Len : Integer; begin Len := Socket.Receive(@Buffer, SizeOf(Buffer) - 1); if Len <= 0 then Exit; Buffer[Len] := #0; Memo.lines.add(StrPas(Buffer)); end; procedure TForm2.FormCreate(Sender: TObject); var NewHSocket : TSocket; begin if paramcount = 1 then Begin caption := ParamStr(1); NewHSocket := StrToIntDef(ParamStr(1),0); Socket.Dup(NewHSocket); End; end; Running this example, the server is listen on port 5000, on prompt I connect to server with "telnet 127.0.0.1 5000"... The client project is executed, but show message "10038". When you say: "Once you have the socket handle for the accepted connection, you may start another process, make it inherit the handle and let him process the connection. The second process may use TWSocket and receive the inherited handle using Dup(). " The implementation above is correct ? If not, have a sample ? Thanks Arnoldo - Original Message - From: "Francois PIETTE" <[EMAIL PROTECTED]> To: "ICS support mailing" Sent: Saturday, May 21, 2005 4:41 AM Subject: Re: [twsocket] Telnet I'm not reinventing the wheel. I saw your samples programs about TWSocketServer too. My problem not is work with various instances of clients. My problem is when the client connect the server, the server redirect the connection to another application. I have the Socket.Accept, I run another application, in this another application who I do establish connection with the client ? It's possible ? Altough I have nerver done this, I think it is possible. Once you have the socket handle for the accepted connection, you may start another process, make it inherit the handle and let him process the connection. The second process may use TWSocket and receive the inherited handle using Dup(). You have somewhat to split TWSocketServer in two parts. The listening part stay in one process and the client handling goes into another one. -- [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 -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Telnet
> ShellExecute(Application.Handle, 'open', @ClientFileName, @ClientParams, > @ClientDir, SW_SHOW); I'm not sure you can use ShellExecute to inherit handles. Use CreateProcess which has a parameter bInheritHandles. > to server with "telnet 127.0.0.1 5000"... The client project is executed, > but show message "10038". Error 10038 means you pass a handle to winsock that is not a socket handle. In your case, the handle is not inherited from the parent process. -- [EMAIL PROTECTED] http://www.overbyte.be - Original Message - From: "Arnoldo - Optextil" <[EMAIL PROTECTED]> To: "ICS support mailing" Sent: Tuesday, May 24, 2005 3:23 PM Subject: Re: [twsocket] Telnet > Hi, > > About redirect the connection, I created two small projects, exemplify the > problem ! > > Server: > > unit UServer; > > interface > > uses > Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, > Dialogs, WSocket, SHELLAPI; > > type > TForm1 = class(TForm) > SrvSocket: TWSocket; > procedure FormCreate(Sender: TObject); > procedure SrvSocketSessionAvailable(Sender: TObject; ErrCode: Word); > private > { Private declarations } > public > { Public declarations } > end; > > var > Form1: TForm1; > > implementation > > {$R *.dfm} > > procedure TForm1.FormCreate(Sender: TObject); > begin > SrvSocket.Close; > SrvSocket.Addr := '0.0.0.0'; { Use any interface for listening } > SrvSocket.Proto := 'tcp'; > SrvSocket.Port := '5000'; > SrvSocket.Listen; > end; > > procedure TForm1.SrvSocketSessionAvailable(Sender: TObject; ErrCode: Word); > var > ClientFileName, ClientParams, ClientDir : array [0..255] of char; > NewHSocket : TSocket; > begin > NewHSocket := SrvSocket.Accept; > StrPCopy(@ClientFileName, 'c:\rf\projectcliente.exe'); > StrPCopy(@ClientParams, ''+ inttostr(newhsocket)); > StrPCopy(@ClientDir, 'c:\rf\'); > ShellExecute(Application.Handle, 'open', @ClientFileName, @ClientParams, > @ClientDir, SW_SHOW); > end; > > Client: > > unit UCliente; > > interface > > uses > Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, > Dialogs, WSocket, Spin, StdCtrls, Buttons, WinSock; > > type > TForm2 = class(TForm) > Socket: TWSocket; > Memo: TMemo; > procedure SocketDataAvailable(Sender: TObject; ErrCode: Word); > procedure FormCreate(Sender: TObject); > private > { Private declarations } > public > { Public declarations } > end; > > var > Form2: TForm2; > > implementation > > {$R *.dfm} > > procedure TForm2.SocketDataAvailable(Sender: TObject; ErrCode: Word); > var > Buffer : array [0..1023] of char; > Len : Integer; > begin > Len := Socket.Receive(@Buffer, SizeOf(Buffer) - 1); > if Len <= 0 then > Exit; > > Buffer[Len] := #0; > Memo.lines.add(StrPas(Buffer)); > end; > > procedure TForm2.FormCreate(Sender: TObject); > var > NewHSocket : TSocket; > begin > if paramcount = 1 then > Begin > caption := ParamStr(1); > NewHSocket := StrToIntDef(ParamStr(1),0); > Socket.Dup(NewHSocket); > End; > end; > > Running this example, the server is listen on port 5000, on prompt I connect > to server with "telnet 127.0.0.1 5000"... The client project is executed, > but > show message "10038". > > When you say: "Once you have the > socket handle for the accepted connection, you may start another process, > make it inherit the handle and let him process the connection. The second > process may use TWSocket and receive the inherited handle using Dup(). " > > The implementation above is correct ? If not, have a sample ? > > Thanks > > Arnoldo > > - Original Message - > From: "Francois PIETTE" <[EMAIL PROTECTED]> > To: "ICS support mailing" > Sent: Saturday, May 21, 2005 4:41 AM > Subject: Re: [twsocket] Telnet > > > >> I'm not reinventing the wheel. I saw your samples programs about > >> TWSocketServer too. My problem not is work with various instances of > >> clients. My problem is when the client connect the server, the server > >> redirect the connection to another application. I have the Socket.Accept, > > I > >> run another application, in this another application who I do establish > >> connection with the client ? It's possible ? > > > > Altough I have ner
Re: [twsocket] Telnet
Hi, About redirect the connection, I created two small projects, exemplify the problem ! Server: unit UServer; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, WSocket, SHELLAPI; type TForm1 = class(TForm) SrvSocket: TWSocket; procedure FormCreate(Sender: TObject); procedure SrvSocketSessionAvailable(Sender: TObject; ErrCode: Word); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); begin SrvSocket.Close; SrvSocket.Addr := '0.0.0.0'; { Use any interface for listening } SrvSocket.Proto := 'tcp'; SrvSocket.Port := '5000'; SrvSocket.Listen; end; procedure TForm1.SrvSocketSessionAvailable(Sender: TObject; ErrCode: Word); var ClientFileName, ClientParams, ClientDir : array [0..255] of char; NewHSocket : TSocket; begin NewHSocket := SrvSocket.Accept; StrPCopy(@ClientFileName, 'c:\rf\projectcliente.exe'); StrPCopy(@ClientParams, ''+ inttostr(newhsocket)); StrPCopy(@ClientDir, 'c:\rf\'); ShellExecute(Application.Handle, 'open', @ClientFileName, @ClientParams, @ClientDir, SW_SHOW); end; Client: unit UCliente; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, WSocket, Spin, StdCtrls, Buttons, WinSock; type TForm2 = class(TForm) Socket: TWSocket; Memo: TMemo; procedure SocketDataAvailable(Sender: TObject; ErrCode: Word); procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form2: TForm2; implementation {$R *.dfm} procedure TForm2.SocketDataAvailable(Sender: TObject; ErrCode: Word); var Buffer : array [0..1023] of char; Len : Integer; begin Len := Socket.Receive(@Buffer, SizeOf(Buffer) - 1); if Len <= 0 then Exit; Buffer[Len] := #0; Memo.lines.add(StrPas(Buffer)); end; procedure TForm2.FormCreate(Sender: TObject); var NewHSocket : TSocket; begin if paramcount = 1 then Begin caption := ParamStr(1); NewHSocket := StrToIntDef(ParamStr(1),0); Socket.Dup(NewHSocket); End; end; Running this example, the server is listen on port 5000, on prompt I connect to server with "telnet 127.0.0.1 5000"... The client project is executed, but show message "10038". When you say: "Once you have the socket handle for the accepted connection, you may start another process, make it inherit the handle and let him process the connection. The second process may use TWSocket and receive the inherited handle using Dup(). " The implementation above is correct ? If not, have a sample ? Thanks Arnoldo - Original Message - From: "Francois PIETTE" <[EMAIL PROTECTED]> To: "ICS support mailing" Sent: Saturday, May 21, 2005 4:41 AM Subject: Re: [twsocket] Telnet I'm not reinventing the wheel. I saw your samples programs about TWSocketServer too. My problem not is work with various instances of clients. My problem is when the client connect the server, the server redirect the connection to another application. I have the Socket.Accept, I run another application, in this another application who I do establish connection with the client ? It's possible ? Altough I have nerver done this, I think it is possible. Once you have the socket handle for the accepted connection, you may start another process, make it inherit the handle and let him process the connection. The second process may use TWSocket and receive the inherited handle using Dup(). You have somewhat to split TWSocketServer in two parts. The listening part stay in one process and the client handling goes into another one. -- [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] Telnet
> I'm not reinventing the wheel. I saw your samples programs about > TWSocketServer too. My problem not is work with various instances of > clients. My problem is when the client connect the server, the server > redirect the connection to another application. I have the Socket.Accept, I > run another application, in this another application who I do establish > connection with the client ? It's possible ? Altough I have nerver done this, I think it is possible. Once you have the socket handle for the accepted connection, you may start another process, make it inherit the handle and let him process the connection. The second process may use TWSocket and receive the inherited handle using Dup(). You have somewhat to split TWSocketServer in two parts. The listening part stay in one process and the client handling goes into another one. -- [EMAIL PROTECTED] http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Telnet
This problem is not related to ICS. Please use a general purpose mailing list or newsgroup. For example http://www.elists.org/mailman/listinfo/delphi btw: You must serialize your requests that must pass thru those "single user" components. Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html -- [EMAIL PROTECTED] The author for the freeware multi-tier middleware MidWare The author of the freeware Internet Component Suite (ICS) http://www.overbyte.be - Original Message - From: "Arnoldo - Optextil" <[EMAIL PROTECTED]> To: "ICS support mailing" Sent: Friday, May 20, 2005 10:31 PM Subject: Re: [twsocket] Telnet > Hi, Arno > > In others two projects, I worked with the examples, a server, a client, > client connect to server, server establish a connection and return to > listen... In this case, the connections simultaneos in server work perfect, > because not acessing global variables. But now, the connections simultaneous > use old routines (I'm not have access to it !), and this routines have > global variables, const, open transactions on data base (one transaction are > accept), etc... If I have two connections and if the two connections open > transaction in old routines, I get a message: "Have a transaction active > !" :( I have try it ! I can control this errors, but the clients will > wait the response... I don't like it ! > > This is a cause of the redirect the connection to another application and > this application accept and establish a connection. If having another > solution, please send-me... Excuse-me my bad english and thanks for the > patience ! > > Arnoldo > > - Original Message - > From: "Arno Garrels" <[EMAIL PROTECTED]> > To: "ICS support mailing" > Sent: Friday, May 20, 2005 4:39 PM > Subject: Re: [twsocket] Telnet > > > > Arnoldo - Optextil wrote: > >> Hi François, > > [snip a lot] > >> Resuming, client connect to server, server execute another application. > >> The > >> another application establishing the connection e work with the client. > >> Have > >> a sample about this ? > > > > As far as I know, there's not such an example. > > But why do you need a second application that service the client > > connection? > > Sounds complicated, is such a design really necessary? > > > > Arno Garrels > > > > > > -- > > 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] Telnet
Hi, Arno In others two projects, I worked with the examples, a server, a client, client connect to server, server establish a connection and return to listen... In this case, the connections simultaneos in server work perfect, because not acessing global variables. But now, the connections simultaneous use old routines (I'm not have access to it !), and this routines have global variables, const, open transactions on data base (one transaction are accept), etc... If I have two connections and if the two connections open transaction in old routines, I get a message: "Have a transaction active !" :( I have try it ! I can control this errors, but the clients will wait the response... I don't like it ! This is a cause of the redirect the connection to another application and this application accept and establish a connection. If having another solution, please send-me... Excuse-me my bad english and thanks for the patience ! Arnoldo - Original Message - From: "Arno Garrels" <[EMAIL PROTECTED]> To: "ICS support mailing" Sent: Friday, May 20, 2005 4:39 PM Subject: Re: [twsocket] Telnet Arnoldo - Optextil wrote: Hi François, [snip a lot] Resuming, client connect to server, server execute another application. The another application establishing the connection e work with the client. Have a sample about this ? As far as I know, there's not such an example. But why do you need a second application that service the client connection? Sounds complicated, is such a design really necessary? Arno Garrels -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Telnet
Arnoldo - Optextil wrote: > Hi François, [snip a lot] > Resuming, client connect to server, server execute another application. > The > another application establishing the connection e work with the client. > Have > a sample about this ? As far as I know, there's not such an example. But why do you need a second application that service the client connection? Sounds complicated, is such a design really necessary? Arno Garrels -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Telnet
Hi François, I'm not reinventing the wheel. I saw your samples programs about TWSocketServer too. My problem not is work with various instances of clients. My problem is when the client connect the server, the server redirect the connection to another application. I have the Socket.Accept, I run another application, in this another application who I do establish connection with the client ? It's possible ? The server only receive connections in a determinete IP/port, if have a connection, it redirect this connection to another application e return to listen. The computer where the server is running, have something the service server, after receive a connection, have the service server and another application serving the client connection (P2P, but not in instance the same project of service server). This another application, only have one connection to the client, if disconnect, the application terminate. Not listen another connections. Resuming, client connect to server, server execute another application. The another application establishing the connection e work with the client. Have a sample about this ? Arnoldo - Original Message - From: "Francois PIETTE" <[EMAIL PROTECTED]> To: "ICS support mailing" Sent: Friday, May 20, 2005 1:04 PM Subject: Re: [twsocket] Telnet But the question 1, OnSessionAvailable on server, I execute this code below: You are reinventing the wheel. Use TWSocketServer instead of TWSocket. It has everything needed to accept incomming connections and manage client list. If you really want to reinvent the wheel, have a look at TWSocketServer source code. Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html -- [EMAIL PROTECTED] The author for the freeware multi-tier middleware MidWare The author of the freeware Internet Component Suite (ICS) http://www.overbyte.be - Original Message - From: "Arnoldo - Optextil" <[EMAIL PROTECTED]> To: "ICS support mailing" Sent: Friday, May 20, 2005 4:24 PM Subject: Re: [twsocket] Telnet François, About Question 2, Ok ! I saw the source code of EmulVT, thanks... But the question 1, OnSessionAvailable on server, I execute this code below: Don't forgot uses shellapi; procedure TForm1.SrvSocketSessionAvailable(Sender: TObject; ErrCode: Word); var ClientFileName, ClientParams, ClientDir : array [0..255] of char; NewHSocket : TSocket; begin NewHSocket := SrvSocket.Accept; Caption := Inttostr(newhsocket); StrPCopy(@ClientFileName, 'c:\atual\project2.exe'); StrPCopy(@ClientParams, ''+ inttostr(newhsocket)); StrPCopy(@ClientDir, 'c:\atual\'); ShellExecute(Application.Handle, 'open', @ClientFileName, @ClientParams, @ClientDir, SW_SHOW); end; in the client application, I establish the connection reading the parameters... This is a bad example to perform this operation ! In your sample programs, you establish the connection in the same project, the application have a form client. Execute a client to receive a connection is necessary, because if I execute two or more clients in the same project, the operations executed by clients not can execute in the same time. A client waiting for another client, do you understand ? This restriction don't is required by communication, but the application that emulated... This application access old routines with sharing memory and I don't have access to source code. If you have a idea about this, i like it ! A code example about establish conection in another application is very good ! :) Thanks Arnoldo - Original Message - From: "Francois Piette" <[EMAIL PROTECTED]> To: "ICS support mailing" Sent: Friday, May 20, 2005 4:47 AM Subject: Re: [twsocket] Telnet >> I'm using ICS - TWSocket and I wrote a server that listen on port, >> waiting a >> connection. A client telnet connect to this IP/port and the server >> execute >> another application to receive this connection. The server is a single >> receive of connections. >> >> Question 1 = Did you already make something similar ? If you made >> this, >> please send-me a example !!! :) > > I'm not sure I understand "execute another application to receive this > connection". > There are several sample programs that accept TCP connections. See the > project group delivered with > ICS. > > >> Question 2 = Do you have anything documentation about emuling terminal >> VT100/VT220 ? I can send to the client telnet commands to position >> cursor, >> make a frame, etc... Do you know this functions ? I saw your sample about >> emuling terminal, server/client. > > You'll find all (well most) function in the EmulVT component which decode > all those escape > sequences for rendering on screen. > Y
Re: [twsocket] Telnet
> But the question 1, OnSessionAvailable on server, I execute this code below: You are reinventing the wheel. Use TWSocketServer instead of TWSocket. It has everything needed to accept incomming connections and manage client list. If you really want to reinvent the wheel, have a look at TWSocketServer source code. Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html -- [EMAIL PROTECTED] The author for the freeware multi-tier middleware MidWare The author of the freeware Internet Component Suite (ICS) http://www.overbyte.be - Original Message - From: "Arnoldo - Optextil" <[EMAIL PROTECTED]> To: "ICS support mailing" Sent: Friday, May 20, 2005 4:24 PM Subject: Re: [twsocket] Telnet > François, > > About Question 2, Ok ! I saw the source code of EmulVT, thanks... > > But the question 1, OnSessionAvailable on server, I execute this code below: > > Don't forgot uses shellapi; > > procedure TForm1.SrvSocketSessionAvailable(Sender: TObject; ErrCode: Word); > var > ClientFileName, ClientParams, ClientDir : array [0..255] of char; > NewHSocket : TSocket; > begin > NewHSocket := SrvSocket.Accept; > Caption := Inttostr(newhsocket); > StrPCopy(@ClientFileName, 'c:\atual\project2.exe'); > StrPCopy(@ClientParams, ''+ inttostr(newhsocket)); > StrPCopy(@ClientDir, 'c:\atual\'); > ShellExecute(Application.Handle, 'open', @ClientFileName, @ClientParams, > @ClientDir, SW_SHOW); > end; > > in the client application, I establish the connection reading the > parameters... > > This is a bad example to perform this operation ! In your sample programs, > you establish the connection in the same project, the application have a > form client. > > Execute a client to receive a connection is necessary, because if I execute > two or more clients in the same project, the operations executed by clients > not can execute in the same time. A client waiting for another client, do > you understand ? This restriction don't is > required by communication, but the application that emulated... This > application access old routines with sharing memory and I don't have access > to source code. > > If you have a idea about this, i like it ! A code example about establish > conection in another application is very good ! :) > > Thanks > > Arnoldo > > > - Original Message - > From: "Francois Piette" <[EMAIL PROTECTED]> > To: "ICS support mailing" > Sent: Friday, May 20, 2005 4:47 AM > Subject: Re: [twsocket] Telnet > > > >> I'm using ICS - TWSocket and I wrote a server that listen on port, > >> waiting a > >> connection. A client telnet connect to this IP/port and the server > >> execute > >> another application to receive this connection. The server is a single > >> receive of connections. > >> > >> Question 1 = Did you already make something similar ? If you made this, > >> please send-me a example !!! :) > > > > I'm not sure I understand "execute another application to receive this > > connection". > > There are several sample programs that accept TCP connections. See the > > project group delivered with > > ICS. > > > > > >> Question 2 = Do you have anything documentation about emuling terminal > >> VT100/VT220 ? I can send to the client telnet commands to position > >> cursor, > >> make a frame, etc... Do you know this functions ? I saw your sample about > >> emuling terminal, server/client. > > > > You'll find all (well most) function in the EmulVT component which decode > > all those escape > > sequences for rendering on screen. > > You'll find plenty documentation by searching with google for "ansi escape > > sequences" (without > > double quotes). > > > > > > -- > > [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 > -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Telnet
François, About Question 2, Ok ! I saw the source code of EmulVT, thanks... But the question 1, OnSessionAvailable on server, I execute this code below: Don't forgot uses shellapi; procedure TForm1.SrvSocketSessionAvailable(Sender: TObject; ErrCode: Word); var ClientFileName, ClientParams, ClientDir : array [0..255] of char; NewHSocket : TSocket; begin NewHSocket := SrvSocket.Accept; Caption := Inttostr(newhsocket); StrPCopy(@ClientFileName, 'c:\atual\project2.exe'); StrPCopy(@ClientParams, ''+ inttostr(newhsocket)); StrPCopy(@ClientDir, 'c:\atual\'); ShellExecute(Application.Handle, 'open', @ClientFileName, @ClientParams, @ClientDir, SW_SHOW); end; in the client application, I establish the connection reading the parameters... This is a bad example to perform this operation ! In your sample programs, you establish the connection in the same project, the application have a form client. Execute a client to receive a connection is necessary, because if I execute two or more clients in the same project, the operations executed by clients not can execute in the same time. A client waiting for another client, do you understand ? This restriction don't is required by communication, but the application that emulated... This application access old routines with sharing memory and I don't have access to source code. If you have a idea about this, i like it ! A code example about establish conection in another application is very good ! :) Thanks Arnoldo - Original Message - From: "Francois Piette" <[EMAIL PROTECTED]> To: "ICS support mailing" Sent: Friday, May 20, 2005 4:47 AM Subject: Re: [twsocket] Telnet I'm using ICS - TWSocket and I wrote a server that listen on port, waiting a connection. A client telnet connect to this IP/port and the server execute another application to receive this connection. The server is a single receive of connections. Question 1 = Did you already make something similar ? If you made this, please send-me a example !!! :) I'm not sure I understand "execute another application to receive this connection". There are several sample programs that accept TCP connections. See the project group delivered with ICS. Question 2 = Do you have anything documentation about emuling terminal VT100/VT220 ? I can send to the client telnet commands to position cursor, make a frame, etc... Do you know this functions ? I saw your sample about emuling terminal, server/client. You'll find all (well most) function in the EmulVT component which decode all those escape sequences for rendering on screen. You'll find plenty documentation by searching with google for "ansi escape sequences" (without double quotes). -- [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] Telnet
> I'm using ICS - TWSocket and I wrote a server that listen on port, waiting a > connection. A client telnet connect to this IP/port and the server execute > another application to receive this connection. The server is a single > receive of connections. > > Question 1 = Did you already make something similar ? If you made this, > please send-me a example !!! :) I'm not sure I understand "execute another application to receive this connection". There are several sample programs that accept TCP connections. See the project group delivered with ICS. > Question 2 = Do you have anything documentation about emuling terminal > VT100/VT220 ? I can send to the client telnet commands to position cursor, > make a frame, etc... Do you know this functions ? I saw your sample about > emuling terminal, server/client. You'll find all (well most) function in the EmulVT component which decode all those escape sequences for rendering on screen. You'll find plenty documentation by searching with google for "ansi escape sequences" (without double quotes). -- [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] Telnet
I'm using ICS - TWSocket and I wrote a server that listen on port, waiting a connection. A client telnet connect to this IP/port and the server execute another application to receive this connection. The server is a single receive of connections. Question 1 = Did you already make something similar ? If you made this, please send-me a example !!! :) Question 2 = Do you have anything documentation about emuling terminal VT100/VT220 ? I can send to the client telnet commands to position cursor, make a frame, etc... Do you know this functions ? I saw your sample about emuling terminal, server/client. _ Arnoldo Uber Junior Analista de Negócios - Tecnologia Operacional Têxtil Consultoria e Sistemas Ltda 47 3234242 Ramal 29 Blumenau - SC - Brasil [EMAIL PROTECTED] (MSN) -- 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