aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-02-17 06:48:48 +0000
committerlloyd <[email protected]>2010-02-17 06:48:48 +0000
commit8855b8bb6f43042fd95b8c0bd5437130d43be9fd (patch)
tree982ff5e0f8988b90ebe8367e61db13e8776a99fd /doc
parent6a2f1e84538afed55f92eb9550f886a51301a84c (diff)
TLS_Server example - more printfs, configurable port
Diffstat (limited to 'doc')
-rw-r--r--doc/examples/tls_server.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/doc/examples/tls_server.cpp b/doc/examples/tls_server.cpp
index 72212de0f..39453dbfd 100644
--- a/doc/examples/tls_server.cpp
+++ b/doc/examples/tls_server.cpp
@@ -19,8 +19,14 @@ using namespace Botan;
#include <iostream>
#include <memory>
-int main()
+int main(int argc, char* argv[])
{
+
+ int port = 4433;
+
+ if(argc == 2)
+ port = to_u32bit(argv[1]);
+
try
{
LibraryInitializer init;
@@ -37,9 +43,9 @@ int main()
X509_Certificate cert =
X509::create_self_signed_cert(options, key, "SHA-1", *rng);
- Unix_Server_Socket listener(4434);
+ Unix_Server_Socket listener(port);
- printf("Now listening...\n");
+ printf("Now listening on port %d...\n", port);
while(true)
{
@@ -50,9 +56,13 @@ int main()
TLS_Server tls(*rng, *sock, cert, key);
+ printf("Writing some text\n");
+
char msg[] = "Foo\nBar\nBaz\nQuux\n";
tls.write((const byte*)msg, strlen(msg));
+ printf("Now trying a read...\n");
+
char buf[10] = { 0 };
u32bit got = tls.read((byte*)buf, 9);
printf("%d: '%s'\n", got, buf);