diff options
Diffstat (limited to 'examples/ssl/extradata.nim')
-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 |