当前位置: 首页>>代码示例>>Python>>正文


Python socket.IPPROTO_SCTP属性代码示例

本文整理汇总了Python中socket.IPPROTO_SCTP属性的典型用法代码示例。如果您正苦于以下问题:Python socket.IPPROTO_SCTP属性的具体用法?Python socket.IPPROTO_SCTP怎么用?Python socket.IPPROTO_SCTP使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在socket的用法示例。


在下文中一共展示了socket.IPPROTO_SCTP属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: newSocket

# 需要导入模块: import socket [as 别名]
# 或者: from socket import IPPROTO_SCTP [as 别名]
def newSocket(self):
        return socket.socket(socket.AF_INET, socket.SOCK_STREAM,
                             socket.IPPROTO_SCTP) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:5,代码来源:test_socket.py

示例2: send

# 需要导入模块: import socket [as 别名]
# 或者: from socket import IPPROTO_SCTP [as 别名]
def send(self, data):
        try:
            if not self.maxsize is None and len(data) > self.maxsize:
                data = data[:self.maxsize-1]
                if DEBUG:
                    print("Truncated data to %d byte." % self.maxsize)
            if self.session_type == "eth":
                self.s.send(data)
            elif self.session_type == "file":
                self.f.write(data)
            elif self.session_type == "stdout":
                self.f.write(data + b"\n")
            elif self.session_type == "stdout-hex":
                self.f.write(binascii.hexlify(data))
            elif self.session_type == "cmd":
                try:
                    subprocess.call("%s %s" % (self.cmd, binascii.hexlify(data).upper()), shell=True)
                except Exception as e:
                    raise dizz_sessionException("error on executing %s: '%s'" % (self.cmd, str(e)))
            elif self.session_type == "usb-dscr":                
                self.u = usb.dizzyUSB(self.filename, self.timeout, data=data, fuzz_dscr=self.fuzz_dscr)
                self.u.open()
                self.u.close()
            elif self.session_type == "usb-endp":
                if not self.u.opened:
                    raise dizz_sessionException("usb connection closed...")
                try:
                    self.u.write(data)
                except ValueError as e:
                    raise dizz_sessionException("error sending to endpoint: %s" % str(e))
            elif self.session_type == "tcp" or self.session_type == "tls":
                if self.server_side:
                    if not self.cs:
                        raise dizz_sessionException("no client connection, cant send")
                    self.cs.send(data)
                else:
                    self.s.send(data)
            #~ elif self.session_type == "sctp":
                #~ self.s.sendmsg([data], [(socket.IPPROTO_SCTP, self.SCTP_SNDRCV, self.sndrcvinfo)], 0, (self.dest, self.dport))
            else:
                self.s.sendto(data, (self.dest, self.dport))
        except Exception as e:
            if self.auto_reopen:
                if DEBUG:
                    print("session got closed '%s', autoreopening..." % str(e))
                    traceback.print_exc()
                self.close()
                self.open()
            else:
                self.close()
                raise dizz_sessionException("error on sending '%s', connection closed." % str(e)) 
开发者ID:ernw,项目名称:dizzy-legacy,代码行数:53,代码来源:dizzy.py


注:本文中的socket.IPPROTO_SCTP属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。