Reputation: 14281
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?
Upvotes: 1
Views: 3368
Reputation: 239341
If you don't want the call to block, you can supply the MSG_DONTWAIT
flag 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.
Upvotes: 5