Git Product home page Git Product logo

Comments (1)

p1-bmu avatar p1-bmu commented on August 20, 2024

This is the help of the high-level sctpsocket object (obtained with sctp.sctpsocket_tcp() or sctp.sctpsocket_udp()):

 |  sctp_recv(self, maxlen)
 |      Receives an SCTP message and/or a SCTP notification event. The notifications
 |      that can be received are regulated by "events" property and its subproperties.
 |      See event_subscribe() class for details.
 |      
 |      It is important to know that sctp_recv() can return either on data messages or
 |      on subscribed events. If the application just wants data, it must unsubscribe
 |      the other events.
 |      
 |      Parameters;
 |      
 |      maxlen: the maximum message size that can be received. If bigger messages are
 |      received, they will be received in fragments (non-atomically). The application 
 |      must choose this carefully if it wants to keep the atomicity of messages!
 |      
 |      Returns: (fromaddr, flags, msg, notif)
 |      
 |      fromaddr: address/port pair. For some applications, association ID will be more
 |                useful to identify the related association. Fortunately, assoc_id is
 |                a attribute of most notifications received via "notif" (see below)
 |      
 |      flags: a bitmap of lower-level recvmsg() flags (FLAG_* flags).  
 |      
 |              FLAG_NOTIFICATION indicates that an event notification was 
 |              returned, instead of a data message.
 |      
 |              FLAG_EOR indicates that this is the final fragment of a data message.
 |              Ideally, all messages will come with this flag set.
 |      
 |             WARNING: message data-related flags like MSG_UNORDERED are returned
 |             inside sndrcvinfo() notifications, and NOT here!
 |      
 |      msg: the actual data message. Since SCTP does not allow empty messages,
 |           an empty "msg" always means something special, either:
 |      
 |              a) that "notif" contains an event notificatoin, if "flags" has 
 |                 FLAG_NOTIFICATION set;
 |      
 |              b) that association is closing (for TCP-style sockets only)
 |      
 |      notif: notification event object. If "msg" is a data message, it will contain
 |             a sndrcvinfo() object that contains metadata about the message. If 
 |             "flags" has FLAG_NOTIFICATION set, it will contain some notification()
 |             subclass.
 |      
 |             sndrcvinfo() is ALWAYS returned when a data message is received, but
 |             it will only contain useful data IF events.data_io is subscribed True.
 |      
 |      WARNING: the maximum message size that can be received via SCTP is limited:
 |      
 |      * by the underlying implementation. Check your operating system.
 |      
 |      * by the "maxlen" parameter passed. If message is bigger, it will be received
 |        in several fragments. The last fragment will have FLAG_EOR flag set.
 |      
 |      * by the socket's reception buffer (SO_SNDRCV). The application must configure 
 |        this buffer accordingly, otherwise the message will be truncacted.
 |  

From here, if you want to know the length of the received data, you can simply use len(msg) after sctp_recv() returns.

from pysctp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.