aboutsummaryrefslogtreecommitdiffstats
path: root/doc/examples/tls_client.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-01-11 22:57:21 +0000
committerlloyd <[email protected]>2010-01-11 22:57:21 +0000
commita4124ddf481bfc56859007b34dea646ecb7f8a25 (patch)
treefd842d8a091c5c529d6c32cd300bc195519ceb46 /doc/examples/tls_client.cpp
parentf5fd85b0ea6a5a6975d595130e029f94fddae9a4 (diff)
Import latest version of Ajisai into src/ssl; once this hits mainline
I'll officially kill off Ajisai (instead of it just lingering as a zombine as it is currently). Apparently I broke something (or multiple things) during the import process; servers crash and clients gets MAC errors on connect.
Diffstat (limited to 'doc/examples/tls_client.cpp')
-rw-r--r--doc/examples/tls_client.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/doc/examples/tls_client.cpp b/doc/examples/tls_client.cpp
new file mode 100644
index 000000000..20fde6354
--- /dev/null
+++ b/doc/examples/tls_client.cpp
@@ -0,0 +1,55 @@
+/*
+* (C) 2008 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#include <botan/init.h>
+#include <botan/tls_client.h>
+#include <botan/unx_sock.h>
+
+using namespace Botan;
+
+#include <stdio.h>
+#include <string>
+#include <iostream>
+#include <memory>
+
+int main()
+ {
+ try
+ {
+ LibraryInitializer init;
+
+ Unix_Socket sock("randombit.net", 443);
+
+ std::auto_ptr<Botan::RandomNumberGenerator> rng(
+ Botan::RandomNumberGenerator::make_rng());
+
+ TLS_Client tls(*rng, sock);
+
+ printf("Connection open\n");
+
+ while(true)
+ {
+ if(tls.is_closed())
+ break;
+
+ std::string str;
+ std::getline(std::cin, str);
+ str += "\n";
+ tls.write((const byte*)str.c_str(), str.length());
+
+ byte buf[4096] = { 0 };
+ tls.read(buf, sizeof(buf));
+ printf("%s", buf);
+ fflush(0);
+ }
+ }
+ catch(std::exception& e)
+ {
+ printf("%s\n", e.what());
+ return 1;
+ }
+ return 0;
+ }