From 38b477027532a7802a7b566391c6d690c9c64788 Mon Sep 17 00:00:00 2001 From: DevOps User Date: Tue, 22 Jun 2021 18:31:22 +0200 Subject: [PATCH] SCTPv2 --- sctp_Client.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 sctp_Client.py diff --git a/sctp_Client.py b/sctp_Client.py new file mode 100644 index 0000000..48fd5fa --- /dev/null +++ b/sctp_Client.py @@ -0,0 +1,46 @@ +import _sctp +import sctp +from sctp import * +import time +import config + +client = "127.0.0.1" +server = "SERVER_IP" +sport = 2904 +cport = 2905 + +if _sctp.getconstant("IPPROTO_SCTP") != 132: + raise (Exception("getconstant failed")) +csocket = sctpsocket(socket.AF_INET, socket.SOCK_STREAM, None) + +saddr = (server, sport) + +print("TCP %r ----------------------------------------------" % (saddr,)) + +csocket.initparams.max_instreams = 3 +csocket.initparams.num_ostreams = 3 +caddr = (client, cport) + +csocket.bindx([caddr]) +csocket.events.clear() +csocket.events.data_io = 1 + +csocket.connect(saddr) + +while 1: + while True: + data = input('input:') + if not data: + break + csocket.sctp_send(data) + fromaddr, flags, msgret, notif = csocket.sctp_recv(1024) + print(" Msg arrived, msg:", msgret) + + if flags & FLAG_NOTIFICATION: + raise (Exception("We did not subscribe to receive notifications!")) + # else: + print("%s" % msgret) + break + +csocket.close() +