def tcpBind(stream, address, port): rffi.setintfield(sin, "c_sin_family", s.AF_INET) rffi.setintfield(sin, "c_sin_port", s.htons(port)) if inet_pton(s.AF_INET, address, sin.c_sin_addr): print "tcpBind: inet_pton failed!?" assert False # No flags. rv = check("tcp_bind", tcp_bind(stream, sin, 0)) return rv
def tcpConnect(stream, address, port, callback): connect = alloc_connect() rffi.setintfield(sin, "c_sin_family", s.AF_INET) rffi.setintfield(sin, "c_sin_port", s.htons(port)) if inet_pton(s.AF_INET, address, sin.c_sin_addr): print "tcpConnect: inet_pton failed!?" assert False rv = check("tcp_connect", tcp_connect(connect, stream, sin, callback)) return rv
def tcp6Connect(stream, address, port, callback): inet, sin, s_addr, s_fam, s_port = af6 connect = alloc_connect() rffi.setintfield(sin, s_fam, inet) rffi.setintfield(sin, s_port, s.htons(port)) if inet_pton(inet, address, getattr(sin, s_addr)): print "tcp6Connect: inet_pton failed!?" assert False rv = check("tcp_connect", tcp_connect(connect, stream, sin, callback)) return rv
def tcp6Bind(stream, address, port): inet, sin, s_addr, s_fam, s_port = af6 rffi.setintfield(sin, s_fam, inet) rffi.setintfield(sin, s_port, s.htons(port)) if inet_pton(inet, address, getattr(sin, s_addr)): print "tcp6Bind: inet_pton failed!?" assert False # No flags. rv = check("tcp_bind", tcp_bind(stream, sin, 0)) return rv
def htons(x): assert isinstance(x, int) return rffi.cast(lltype.Signed, _c.htons(x))
def htons(x): return rffi.cast(lltype.Signed, _c.htons(x))