Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-updates > by-pkgid > efe60a74a55b1603654f3f258ba7199d > files > 2874

python3-twisted-19.2.1-1.1.mga7.armv7hl.rpm

# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.

"""
Demonstration of sending bytes over a TCP connection using sendmsg.
"""

from __future__ import print_function

from socket import socketpair

from twisted.python.sendmsg import sendmsg, recvmsg

def main():
    foo, bar = socketpair()
    sent = sendmsg(foo, b"Hello, world")
    print("Sent", sent, "bytes")
    (received, ancillary, flags) = recvmsg(bar, 1024)
    print("Received", repr(received))
    print("Extra stuff, boring in this case", flags, ancillary)

if __name__ == '__main__':
    main()