- 論壇徽章:
- 0
|
下面的是服務器端的監(jiān)聽程序:
GError* error = NULL;
int sock,s;
BIO *sbio, *bbio, *acpt;
SSL_CTX *ctx;
SSL *ssl;
/* Build our SSL context*/
ctx=initialize_ctx("./cert/servercert.pem",
"./cert/serverkey.pem",PASSWORD);
// load_dh_params(ctx,DHFILE);
sbio = BIO_new_ssl (ctx,0);
BIO_get_ssl(sbio, &ssl);
if (!ssl)
{
g_printerr("Can't locate SSL pointer\n");
return -1;
}
/* Don't want any retries */
SSL_set_mode (ssl, SSL_MODE_AUTO_RETRY);
/* Create the buffering BIO */
bbio = BIO_new (BIO_f_buffer ());
/* Add to chain */
sbio = BIO_push (bbio, sbio);
gchar* port = g_strdup_printf ("%d", listen_port);
acpt=BIO_new_accept (port);
g_free (port);
/* By doing this when a new connection is established
* we automatically have sbio inserted into it. The
* BIO chain is now 'swallowed' by the accept BIO and
* will be freed when the accept BIO is freed.
*/
BIO_set_accept_bios (acpt,sbio);
// BIO_set_accept_port(acpt, "*:54999");
/* Setup accept BIO */
if (BIO_do_accept (acpt) <= 0)
{
fprintf(stderr, "Error setting up accept BIO\n");
ERR_print_errors_fp(stderr);
return -1;
}
while (1)
{
/* Now wait for incoming connection */
if (BIO_do_accept (acpt) <= 0)
{
fprintf(stderr, "Error in connection\n");
ERR_print_errors_fp(stderr);
return -1;
}
BIO * c_sbio = BIO_pop (acpt); /* c_sbio may be is the childe of sbio ??*/
if( !g_thread_create((GThreadFunc)minp_response, c_sbio, FALSE, &error) )
{
g_printerr("協(xié)議分析線程\n");
}
}
BIO_free_all (acpt);
SSL_CTX_free (ctx);
g_thread_exit(0);
這上面是用BIO改后的程序,原來用的是SSL?蛻舳四苓B原來的,但是改后就不能連了!熬芙^連接”。
我想問題可能是上面服務器端的問題。我用 netstat -tlp ,查看到,服務器端正在監(jiān)聽端口,本地地址是"localhost:4999",請各位大俠幫忙看看,有什么問題
[此貼被hecate_eos在2010-09-9 3:50 PM重新編輯] |
|