Author Topic: HTTPS Server  (Read 3602 times)

dcipher

  • Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
HTTPS Server
« on: November 09, 2017, 03:51:06 PM »
Hi

I am just wondering how a socket server for receiving rest requests via SSL should be created using Chilkat socket.  The examples are all based on a single connection.  So my question is do you simply put the CkSocket::ckAcceptNextConnection(listenSslSocket,maxWaitMillisec) in a loop and keep checking for a connection.  If that is the case I assume that the maxWaitMilliSec should be fairly short in order handle multiple requests in a timely fashion.

So I am just wondering what the recommended procedure should be.

Thanks,
Simon

Chilkat

  • Administrator
  • Full Member
  • *****
  • Posts: 103
  • Karma: +7/-0
    • View Profile
Re: HTTPS Server
« Reply #1 on: December 08, 2017, 02:38:38 PM »
The most straightforward way of implementing such a thing would be to use separate threads.  (Look to your particular programming language for information about multi-threaded programming.)  Assuming you know how to create a thread in your programming language, have one thread be the "accept connection" thread.  It just sits and waits for an incoming connection by calling AcceptNextConnection.  When a connection is received, AcceptNextConnection returns the connected socket object, and you can start a new thread to specifically handle that connection.  You would pass the connected socket object to the new thread, which now owns it.  Meanwhile, your "accept connection" thread, just loops to call AcceptNextConnection again to receive the next incoming connection, etc..