Jump to content
JohnF

TSslWSocket SSL issue on Console

Recommended Posts

Hi

 

Just started using ICS, I have a client that is talking to a TCP server. The GUI version works fine, the console version is not passing the SSL

OndataAvailable is used for returning the data

OnChangeState and Onhandshake are there for testing only

 

On the console app;

 

{$DEFINE NOFORMS}

 

I have read that for consoles you need to have a message pump, how ever I'm not exactly sure where to plug it in.

 

mySocket.OnMessagePump looks to be the obvious choice, and exactly which message calls are required.

 

at the moment everything is running in the one main thread, however I might have to move it to its own thread later,

 

A small example would be fab.

 

Cheers

  FSslContext:= TSslContext.Create(Nil);
  FtcpSocket:= TSslWSocket.Create(Nil);

  tcpSocket.Name := 'icsReplayTcp';

  tcpSocket.OnDataAvailable     := SocketDataAvailable;
  tcpSocket.OnChangeState       := SocketChangeState;
  tcpSocket.OnSslHandshakeDone  := SocketSslHandshakeDone;
  tcpSocket.OnMessagePump       := MyMessagePump;


  tcpSocket.Port := '1234';
  tcpSocket.Addr := 'mytcpsoctet.com';

  tcpSocket.SslContext := SslContext;
  tcpSocket.SslEnable  := True;
  tcpSocket.Proto := 'tcp';

  tcpSocket.SslContext.SslCAFile := 'CA.pem';
  tcpSocket.SslContext.SslCertFile := 'DEMO3.pem';

  TcpSocket.Connect;


.....


procedure TICSReplay.MyMessagePump(Sender: TObject);
begin
  tcpSocket.MessageLoop;
end;

 

Share this post


Link to post

Have a look at the sample OverbyteIcsConHttp.dpr in ICS distribution.

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×