License:
Author:
1 2 3 4 5 6 7 8 9 10 | auto s = new SSLSocket; if (s.connect("www.yahoo.com", 443)) { char[1024] buff; s.write("GET / HTTP/1.0\r\n\r\n"); auto bytesRead = s.read(buff); if (bytesRead != s.Eof) Stdout.formatln("received: {}", buff[0..bytesRead]); } |
Parameters:
ctx | SSLCtx class as provided by PKI |
clientMode | if true, the socket will be in Client Mode, Server otherwise. |
1 2 3 4 5 6 7 8 9 10 11 | auto cert = new Certificate(cast(char[])File.get("public.pem")); auto pkey = new PrivateKey(cast(char[])File.get("private.pem")); auto ctx = new SSLCtx; ctx.certificate(cert).privateKey(pkey); auto server = new SSLServerSocket(443, ctx); for(;;) { auto sc = server.accept; sc.write("HTTP/1.1 200\r\n\r\n<b>Hello World</b>"); sc.shutdown.close; } |
Parameters:
addr | the address to bind and listen on. |
ctx | the provided SSLCtx |
backlog | the number of connections to backlog before refusing connection |
reuse | if enabled, allow rebinding of existing ip/port |