summaryrefslogtreecommitdiff
path: root/examples/IPC_SAP
diff options
context:
space:
mode:
authorOssama Othman <ossama-othman@users.noreply.github.com>2000-04-26 00:39:26 +0000
committerOssama Othman <ossama-othman@users.noreply.github.com>2000-04-26 00:39:26 +0000
commit9c7f9e8ecad61a5343ece4bec8221ac824368c24 (patch)
treec5f29170281eb2066786c5cc3600e19beae4135e /examples/IPC_SAP
parent0f6aa4f631799ac691690f08d5415d2e5835ee12 (diff)
downloadATCD-9c7f9e8ecad61a5343ece4bec8221ac824368c24.tar.gz
ChangeLogTag:Tue Apr 25 17:27:06 2000 Ossama Othman <ossama@uci.edu>
Diffstat (limited to 'examples/IPC_SAP')
-rw-r--r--examples/IPC_SAP/SSL_SAP/Makefile42
-rw-r--r--examples/IPC_SAP/SSL_SAP/SSL-client.cpp17
-rw-r--r--examples/IPC_SAP/SSL_SAP/SSL-server.cpp60
3 files changed, 73 insertions, 46 deletions
diff --git a/examples/IPC_SAP/SSL_SAP/Makefile b/examples/IPC_SAP/SSL_SAP/Makefile
index 089ceb215ec..098fd29d869 100644
--- a/examples/IPC_SAP/SSL_SAP/Makefile
+++ b/examples/IPC_SAP/SSL_SAP/Makefile
@@ -61,8 +61,10 @@ endif
$(ACE_ROOT)/ace/pre.h \
$(ACE_ROOT)/ace/ACE.h \
$(ACE_ROOT)/ace/OS.h \
- $(ACE_ROOT)/ace/inc_user_config.h \
$(ACE_ROOT)/ace/post.h \
+ $(ACE_ROOT)/ace/ace_wchar.h \
+ $(ACE_ROOT)/ace/ACE_export.h \
+ $(ACE_ROOT)/ace/svc_export.h \
$(ACE_ROOT)/ace/Min_Max.h \
$(ACE_ROOT)/ace/streams.h \
$(ACE_ROOT)/ace/Basic_Types.h \
@@ -154,8 +156,10 @@ endif
$(ACE_ROOT)/ace/pre.h \
$(ACE_ROOT)/ace/ACE.h \
$(ACE_ROOT)/ace/OS.h \
- $(ACE_ROOT)/ace/inc_user_config.h \
$(ACE_ROOT)/ace/post.h \
+ $(ACE_ROOT)/ace/ace_wchar.h \
+ $(ACE_ROOT)/ace/ACE_export.h \
+ $(ACE_ROOT)/ace/svc_export.h \
$(ACE_ROOT)/ace/Min_Max.h \
$(ACE_ROOT)/ace/streams.h \
$(ACE_ROOT)/ace/Basic_Types.h \
@@ -223,8 +227,10 @@ endif
$(ACE_ROOT)/ace/Thread.h \
$(ACE_ROOT)/ace/ACE.h \
$(ACE_ROOT)/ace/OS.h \
- $(ACE_ROOT)/ace/inc_user_config.h \
$(ACE_ROOT)/ace/post.h \
+ $(ACE_ROOT)/ace/ace_wchar.h \
+ $(ACE_ROOT)/ace/ACE_export.h \
+ $(ACE_ROOT)/ace/svc_export.h \
$(ACE_ROOT)/ace/Min_Max.h \
$(ACE_ROOT)/ace/streams.h \
$(ACE_ROOT)/ace/Basic_Types.h \
@@ -318,8 +324,10 @@ endif
$(ACE_ROOT)/ace/Synch_Options.h \
$(ACE_ROOT)/ace/ACE.h \
$(ACE_ROOT)/ace/OS.h \
- $(ACE_ROOT)/ace/inc_user_config.h \
$(ACE_ROOT)/ace/post.h \
+ $(ACE_ROOT)/ace/ace_wchar.h \
+ $(ACE_ROOT)/ace/ACE_export.h \
+ $(ACE_ROOT)/ace/svc_export.h \
$(ACE_ROOT)/ace/Min_Max.h \
$(ACE_ROOT)/ace/streams.h \
$(ACE_ROOT)/ace/Basic_Types.h \
@@ -479,8 +487,10 @@ endif
$(ACE_ROOT)/ace/Thread.h \
$(ACE_ROOT)/ace/ACE.h \
$(ACE_ROOT)/ace/OS.h \
- $(ACE_ROOT)/ace/inc_user_config.h \
$(ACE_ROOT)/ace/post.h \
+ $(ACE_ROOT)/ace/ace_wchar.h \
+ $(ACE_ROOT)/ace/ACE_export.h \
+ $(ACE_ROOT)/ace/svc_export.h \
$(ACE_ROOT)/ace/Min_Max.h \
$(ACE_ROOT)/ace/streams.h \
$(ACE_ROOT)/ace/Basic_Types.h \
@@ -573,8 +583,10 @@ endif
$(ACE_ROOT)/ace/pre.h \
$(ACE_ROOT)/ace/ACE.h \
$(ACE_ROOT)/ace/OS.h \
- $(ACE_ROOT)/ace/inc_user_config.h \
$(ACE_ROOT)/ace/post.h \
+ $(ACE_ROOT)/ace/ace_wchar.h \
+ $(ACE_ROOT)/ace/ACE_export.h \
+ $(ACE_ROOT)/ace/svc_export.h \
$(ACE_ROOT)/ace/Min_Max.h \
$(ACE_ROOT)/ace/streams.h \
$(ACE_ROOT)/ace/Basic_Types.h \
@@ -599,26 +611,26 @@ endif
$(ACE_ROOT)/ace/SOCK.i \
$(ACE_ROOT)/ace/SOCK_IO.i \
$(ACE_ROOT)/ace/SOCK_Stream.i \
- ../../SSLIOP/SSL_SOCK.h ../../SSLIOP/SSL_Export.h \
- ../../SSLIOP/SSL_SOCK.i ../../SSLIOP/SSL_Context.h \
- $(ACE_ROOT)/ace/SString.h \
- $(ACE_ROOT)/ace/SString.i \
- $(ACE_ROOT)/ace/Malloc_Base.h \
- $(ACE_ROOT)/ace/Singleton.h \
+ $(ACE_ROOT)/ace/Synch_T.h \
+ $(ACE_ROOT)/ace/Event_Handler.h \
+ $(ACE_ROOT)/ace/Event_Handler.i \
$(ACE_ROOT)/ace/Synch.h \
$(ACE_ROOT)/ace/SV_Semaphore_Complex.h \
$(ACE_ROOT)/ace/SV_Semaphore_Simple.h \
$(ACE_ROOT)/ace/SV_Semaphore_Simple.i \
$(ACE_ROOT)/ace/SV_Semaphore_Complex.i \
$(ACE_ROOT)/ace/Synch.i \
- $(ACE_ROOT)/ace/Synch_T.h \
- $(ACE_ROOT)/ace/Event_Handler.h \
- $(ACE_ROOT)/ace/Event_Handler.i \
$(ACE_ROOT)/ace/Synch_T.i \
$(ACE_ROOT)/ace/Thread.h \
$(ACE_ROOT)/ace/Thread.i \
$(ACE_ROOT)/ace/Atomic_Op.i \
$(ACE_ROOT)/ace/Synch_T.cpp \
+ ../../SSLIOP/SSL_SOCK.h ../../SSLIOP/SSL_Export.h \
+ ../../SSLIOP/SSL_SOCK.i ../../SSLIOP/SSL_Context.h \
+ $(ACE_ROOT)/ace/SString.h \
+ $(ACE_ROOT)/ace/SString.i \
+ $(ACE_ROOT)/ace/Malloc_Base.h \
+ $(ACE_ROOT)/ace/Singleton.h \
$(ACE_ROOT)/ace/Singleton.i \
$(ACE_ROOT)/ace/Singleton.cpp \
$(ACE_ROOT)/ace/Object_Manager.h \
diff --git a/examples/IPC_SAP/SSL_SAP/SSL-client.cpp b/examples/IPC_SAP/SSL_SAP/SSL-client.cpp
index 733bbcd8e1e..42d9f2b79f6 100644
--- a/examples/IPC_SAP/SSL_SAP/SSL-client.cpp
+++ b/examples/IPC_SAP/SSL_SAP/SSL-client.cpp
@@ -346,10 +346,13 @@ Options::twoway_client_test (void *)
timer.elapsed_time_incr (tv);
double real_time = tv.sec () * ACE_ONE_SECOND_IN_USECS + tv.usec ();
- double messages_per_sec = iteration * double (ACE_ONE_SECOND_IN_USECS) / real_time;
+ double messages_per_sec =
+ iteration * double (ACE_ONE_SECOND_IN_USECS) / real_time;
ACE_DEBUG ((LM_DEBUG,
- ASYS_TEXT ("(%t) messages = %d\n(%t) usec-per-message = %f\n(%t) messages-per-second = %0.00f\n"),
+ ASYS_TEXT ("(%t) messages = %d\n")
+ ASYS_TEXT ("(%t) usec-per-message = %f\n")
+ ASYS_TEXT ("(%t) messages-per-second = %0.00f\n"),
iteration,
real_time / double (iteration),
messages_per_sec < 0 ? 0 : messages_per_sec));
@@ -377,8 +380,9 @@ run_client (void)
ACE::set_handle_limit ();
#if defined (ACE_HAS_THREADS)
- if (ACE_Thread_Manager::instance ()->spawn_n (OPTIONS::instance ()->threads (),
- OPTIONS::instance ()->thr_func ()) == -1)
+ if (ACE_Thread_Manager::instance ()->spawn_n (
+ OPTIONS::instance ()->threads (),
+ OPTIONS::instance ()->thr_func ()) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) %p\n",
"spawn_n"),
@@ -394,6 +398,11 @@ run_client (void)
int
main (int argc, char *argv[])
{
+ ACE_SSL_Context *context = ACE_SSL_Context::instance ();
+
+ context->certificate ("./dummy.pem", SSL_FILETYPE_PEM);
+ context->private_key ("./key.pem", SSL_FILETYPE_PEM);
+
// Initialize the logger.
ACE_LOG_MSG->open (argv[0]);
diff --git a/examples/IPC_SAP/SSL_SAP/SSL-server.cpp b/examples/IPC_SAP/SSL_SAP/SSL-server.cpp
index 27ce9c8c957..71685fd3c17 100644
--- a/examples/IPC_SAP/SSL_SAP/SSL-server.cpp
+++ b/examples/IPC_SAP/SSL_SAP/SSL-server.cpp
@@ -18,13 +18,13 @@ static int verbose = 0;
static void
run_server (ACE_THR_FUNC server,
- ACE_HANDLE handle)
+ ACE_SSL_SOCK_Stream *new_stream)
{
#if defined (ACE_HAS_THREADS)
// Spawn a new thread and run the new connection in that thread of
// control using the <server> function as the entry point.
if (ACE_Thread_Manager::instance ()->spawn (server,
- (void *) handle,
+ (void *) new_stream,
THR_DETACHED) == -1)
ACE_ERROR ((LM_ERROR,
"(%P|%t) %p\n",
@@ -40,18 +40,15 @@ static void *
twoway_server (void *arg)
{
ACE_INET_Addr cli_addr;
- ACE_SSL_SOCK_Stream new_stream;
- ACE_HANDLE handle = (ACE_HANDLE) (long) arg;
-
- new_stream.set_handle (handle);
+ ACE_SSL_SOCK_Stream * new_stream = (ACE_SSL_SOCK_Stream *) arg;
// Make sure we're not in non-blocking mode.
- if (new_stream.disable (ACE_NONBLOCK) == -1)
+ if (new_stream->disable (ACE_NONBLOCK) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
"%p\n",
"disable"),
0);
- else if (new_stream.get_remote_addr (cli_addr) == -1)
+ else if (new_stream->get_remote_addr (cli_addr) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
"%p\n",
"get_remote_addr"),
@@ -73,7 +70,7 @@ twoway_server (void *arg)
{
ACE_INT32 len;
- ssize_t r_bytes = new_stream.recv_n ((void *) &len,
+ ssize_t r_bytes = new_stream->recv_n ((void *) &len,
sizeof (ACE_INT32));
if (r_bytes == -1)
{
@@ -104,7 +101,7 @@ twoway_server (void *arg)
}
// Subtract off the sizeof the length prefix.
- r_bytes = new_stream.recv_n (request,
+ r_bytes = new_stream->recv_n (request,
len - sizeof (ACE_UINT32));
if (r_bytes == -1)
{
@@ -116,7 +113,8 @@ twoway_server (void *arg)
else if (r_bytes == 0)
{
ACE_DEBUG ((LM_DEBUG,
- "(%P|%t) reached end of input, connection closed by client\n"));
+ "(%P|%t) reached end of input, "
+ "connection closed by client\n"));
break;
}
else if (verbose
@@ -126,7 +124,7 @@ twoway_server (void *arg)
ACE_ERROR ((LM_ERROR,
"%p\n",
"ACE::write_n"));
- else if (new_stream.send_n (request,
+ else if (new_stream->send_n (request,
r_bytes) != r_bytes)
ACE_ERROR ((LM_ERROR,
"%p\n",
@@ -140,7 +138,7 @@ twoway_server (void *arg)
}
// Close new endpoint (listening endpoint stays open).
- new_stream.close ();
+ new_stream->close ();
delete [] request;
return 0;
@@ -152,18 +150,15 @@ static void *
oneway_server (void *arg)
{
ACE_INET_Addr cli_addr;
- ACE_SSL_SOCK_Stream new_stream;
- ACE_HANDLE handle = (ACE_HANDLE) (long) arg;
-
- new_stream.set_handle (handle);
+ ACE_SSL_SOCK_Stream * new_stream = (ACE_SSL_SOCK_Stream *) arg;
// Make sure we're not in non-blocking mode.
- if (new_stream.disable (ACE_NONBLOCK) == -1)
+ if (new_stream->disable (ACE_NONBLOCK) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
"%p\n",
"disable"),
0);
- else if (new_stream.get_remote_addr (cli_addr) == -1)
+ else if (new_stream->get_remote_addr (cli_addr) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
"%p\n",
"get_remote_addr"),
@@ -189,7 +184,7 @@ oneway_server (void *arg)
{
ACE_INT32 len;
- ssize_t r_bytes = new_stream.recv_n ((void *) &len,
+ ssize_t r_bytes = new_stream->recv_n ((void *) &len,
sizeof (ACE_INT32));
if (r_bytes == -1)
{
@@ -220,7 +215,7 @@ oneway_server (void *arg)
}
// Subtract off the sizeof the length prefix.
- r_bytes = new_stream.recv_n (request,
+ r_bytes = new_stream->recv_n (request,
len - sizeof (ACE_UINT32));
if (r_bytes == -1)
@@ -255,7 +250,9 @@ oneway_server (void *arg)
timer.elapsed_time (et);
ACE_DEBUG ((LM_DEBUG,
- ASYS_TEXT ("\t\treal time = %f secs \n\t\tuser time = %f secs \n\t\tsystem time = %f secs\n"),
+ ASYS_TEXT ("\t\treal time = %f secs \n")
+ ASYS_TEXT ("\t\tuser time = %f secs \n")
+ ASYS_TEXT ("\t\tsystem time = %f secs\n"),
et.real_time,
et.user_time,
et.system_time));
@@ -263,7 +260,11 @@ oneway_server (void *arg)
double messages_per_sec = double (message_count) / et.real_time;
ACE_DEBUG ((LM_DEBUG,
- ASYS_TEXT ("\t\tmessages = %d\n\t\ttotal bytes = %d\n\t\tmbits/sec = %f\n\t\tusec-per-message = %f\n\t\tmessages-per-second = %0.00f\n"),
+ ASYS_TEXT ("\t\tmessages = %d\n")
+ ASYS_TEXT ("\t\ttotal bytes = %d\n")
+ ASYS_TEXT ("\t\tmbits/sec = %f\n")
+ ASYS_TEXT ("\t\tusec-per-message = %f\n")
+ ASYS_TEXT ("\t\tmessages-per-second = %0.00f\n"),
message_count,
total_bytes,
(((double) total_bytes * 8) / et.real_time) / (double) (1024 * 1024),
@@ -271,7 +272,7 @@ oneway_server (void *arg)
messages_per_sec < 0 ? 0 : messages_per_sec));
// Close new endpoint (listening endpoint stays open).
- new_stream.close ();
+ new_stream->close ();
delete [] request;
return 0;
@@ -351,10 +352,10 @@ run_event_loop (u_short port)
else
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) spawning twoway server\n"));
-
+
// Run the twoway server.
run_server (twoway_server,
- new_stream.get_handle ());
+ &new_stream);
}
if (temp.is_set (oneway_acceptor.get_handle ()))
{
@@ -369,7 +370,7 @@ run_event_loop (u_short port)
// Run the oneway server.
run_server (oneway_server,
- new_stream.get_handle ());
+ &new_stream);
}
}
}
@@ -380,6 +381,11 @@ run_event_loop (u_short port)
int
main (int argc, char *argv[])
{
+ ACE_SSL_Context *context = ACE_SSL_Context::instance ();
+
+ context->certificate ("./dummy.pem", SSL_FILETYPE_PEM);
+ context->private_key ("./key.pem", SSL_FILETYPE_PEM);
+
u_short port = ACE_DEFAULT_SERVER_PORT;
if (argc > 1)