mirror of https://github.com/vacp2p/nim-webrtc.git
add sctp examples
This commit is contained in:
parent
c28ae5ca31
commit
8e826f7eb2
|
@ -0,0 +1,14 @@
|
||||||
|
import chronos, stew/byteutils
|
||||||
|
import ../webrtc/sctp
|
||||||
|
|
||||||
|
proc main() {.async.} =
|
||||||
|
let
|
||||||
|
sctp = Sctp.new(port = 4244)
|
||||||
|
address = TransportAddress(initTAddress("127.0.0.1:4242"))
|
||||||
|
conn = await sctp.connect(address, sctpPort = 13)
|
||||||
|
await conn.write("test".toBytes)
|
||||||
|
let msg = await conn.read()
|
||||||
|
echo "Client read() finished ; receive: ", string.fromBytes(msg)
|
||||||
|
await conn.close()
|
||||||
|
|
||||||
|
waitFor(main())
|
|
@ -0,0 +1,13 @@
|
||||||
|
import chronos, stew/byteutils
|
||||||
|
import ../webrtc/sctp
|
||||||
|
|
||||||
|
proc main() {.async.} =
|
||||||
|
let sctp = Sctp.new(port = 4242)
|
||||||
|
sctp.startServer(13)
|
||||||
|
let conn = await sctp.listen()
|
||||||
|
let msg = await conn.read()
|
||||||
|
echo "Receive: ", string.fromBytes(msg)
|
||||||
|
await conn.close()
|
||||||
|
sctp.stopServer()
|
||||||
|
|
||||||
|
waitFor(main())
|
Loading…
Reference in New Issue