1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
int main(int argc, char *argv[])
{
int m, s;
struct soap soap, *tsoap;
soap_ssl_init(); /* init OpenSSL (just once) */
soap_init(&soap);
if (soap_ssl_server_context(&soap,
SOAP_SSL_NO_AUTHENTICATION,
NULL, /* keyfile: required when server must authenticate to clients (see SSL docs on how to obtain this file) */
NULL, /* password to read the key file (not used with GNUTLS) */
NULL, /* optional cacert file to store trusted certificates */
NULL, /* optional capath to directory with trusted certificates */
NULL, /* DH file name or DH key len bits (minimum is 512, e.g. "512") to generate DH param, if NULL use RSA */
NULL, /* if randfile!=NULL: use a file with random data to seed randomness */
NULL /* optional server identification to enable SSL session cache (must be a unique name) */ ))
{
soap_print_fault(&soap, stderr);
exit(1);
}
m = soap_bind(&soap, "192.168.1.104", 5880, 100); // use port 18000
if (m < 0)
{
soap_print_fault(&soap, stderr);
exit(1);
}
fprintf(stderr, "Socket connection successful: master socket = %d\n", m);
for (int i = 1; ; i++)
{
s = soap_accept(&soap);
s = soap_ssl_accept(&soap);
fprintf(stderr, "Socket connection successful: slave socket = %d\n", s);
if (s < 0)
{
soap_print_fault(&soap, stderr);
break;
}
fprintf(stderr, "%d: accepted connection from IP=%d.%d.%d.%d socket=%d \n", i,
(soap.ip >> 24)&0xFF, (soap.ip >> 16)&0xFF, (soap.ip >> 8)&0xFF, soap.ip&0xFF, s);
tsoap = soap_copy(&soap); /* should call soap_ssl_accept on a copy */
if (!tsoap)
break;
if (soap_serve(&soap) != SOAP_OK) // process RPC request
{
fmo_soap_print_fault(&soap, stderr); // print error
//fmo_soap_print_fault_location(&soap, stderr); // print error
}
fprintf(stderr, "request served\n");
}
soap_done(&soap); /* deallocates SSL context */
return 0;
} |
Partager