Not blocking after disconnect (General questions)
Email
Anonymous
Not blocking after disconnect 21-07-2006 02:15
Hi,
I have a problem where i connect to a telnet host (this works fine), i then disconnect the component and attempt to reconnect (this fails).
I have traced the problem to the WodSSH component behaving differently after the disconnect1 method is called (i use delphi).
It looks like after the discconect1 method is called, the blocking property is only half used. eg. I can call the WaitFor method but it always fails, this is because the recieve events are still being fired and data is being captured by them. I have put the example code below. Does anyone have any suggestions?
FTelnet := TwodSSHCom.Create( nil );
// hook up the events
FTelnet.OnReceived := wodSSHCom1Received;
FTelnet.OnDisconnected := wodSSHCom1Disconnected;
FTelnet.KeepAlives := 0;
FTelnet.Timeout := 0;
FTelnet.Blocking := true;
FTelnet.StripANSI := true;
FTelnet.Protocol := Telnet;
FTelnet.Connect1( '192.168.86.1' , 23 );
Data := FTelnet.WaitFor( 'login:' , 15 );
FTelnet.Send( 'myLogon' + #13#10 );
Data := FTelnet.WaitFor( 'Password:' , 15 );
FTelnet.Send( 'myPassword' + #13#10);
Data := FTelnet.WaitFor( 'OK' , 15 );
//everything works up until this point
FTelnet.Disconnect1(15);
// reconnect back to server. This works ok.
FTelnet.Connect1( '192.168.86.1' , 23 );
//wait for login prompt. This waitFor fails after the timeout but the onReceive event is fired multiple times with the correct login prompt in data. Looks like blocking is not working properly, even if i reset it.
Data := FTelnet.WaitFor( 'login:' , 15 );