我想建立一个非阻塞的 OpenSSL 连接
在此连接上 - 如果没有可供读取的数据,则整个程序执行流程会在 SSL_read() 上停止。我想要这样,如果没有可供读取的数据,它会给我像 WANT_READ 这样的返回值,我知道没有更多的数据可用。
char *sslRead (connection *c)
{
const int readSize = 1024;
char *rc = NULL;
int r;
int received, count = 0;
int ReallocSize = 0;
char buffer[1024];
if (c)
{
while (1)
{
if (!rc)
{
rc = malloc (readSize + 1);
if (rc == NULL)
printf("the major error have happen. leave program\n");
}
else
{
ReallocSize = (count + 1) * (readSize + 1);
rc = realloc (rc, ReallocSize); …Run Code Online (Sandbox Code Playgroud)