Skip to content

Commit

Permalink
SCTPv2
Browse files Browse the repository at this point in the history
  • Loading branch information
DevOps User committed Jun 22, 2021
1 parent 27f857d commit 38b4770
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions sctp_Client.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 38b4770

Please sign in to comment.