diff options
author | Michał Zieliński <michal@zielinscy.org.pl> | 2015-10-22 23:51:52 +0200 |
---|---|---|
committer | Michał Zieliński <michal@zielinscy.org.pl> | 2015-10-24 08:53:06 +0200 |
commit | 3ebf27ddd24c04e87e33bfb6f8617d81c9fc1946 (patch) | |
tree | f9eda281e1a0c287196ab9b9f1a26b6291d529e1 /examples | |
parent | a90e23a4ddbef38cdf48c59e68630999c6e90374 (diff) | |
download | Nim-3ebf27ddd24c04e87e33bfb6f8617d81c9fc1946.tar.gz |
net.nim: support storing arbitrary data inside SSLContext
Diffstat (limited to 'examples')
-rw-r--r-- | examples/ssl/extradata.nim | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/examples/ssl/extradata.nim b/examples/ssl/extradata.nim new file mode 100644 index 000000000..f86dc57f2 --- /dev/null +++ b/examples/ssl/extradata.nim @@ -0,0 +1,14 @@ +# Stores extra data inside the SSL context. +import net + +# Our unique index for storing foos +let fooIndex = getSslContextExtraDataIndex() +# And another unique index for storing foos +let barIndex = getSslContextExtraDataIndex() +echo "got indexes ", fooIndex, " ", barIndex + +let ctx = newContext() +assert ctx.getExtraData(fooIndex) == nil +let foo: int = 5 +ctx.setExtraData(fooIndex, cast[pointer](foo)) +assert cast[int](ctx.getExtraData(fooIndex)) == foo |