Only once, when a new connection is created, I want to peek into the stream to determine whether or not the connection is an SSL connection. To do this I use recv() with the MSG_PEEK flag. The problem is that for connections which are not SSL connections and dont have any initial incoming data the recv blocks for a few seconds. How do I fix that?
Share
If you don’t want the call to block, you can supply the
MSG_DONTWAITflag as well (not POSIX, but widely implemented) – but how would you tell the difference between an SSL connection where the initial data just hasn’t arrived yet and a non-SSL connection?It seems that to do this reliably you will need to wait for the first portion of data to arrive anyway.