def getaddrinfo(host, port, family=AF_INET, socktype=SOCK_STREAM, proto=IPPROTO_IP, flags=None): entry = _safe_gethostbyname(host) family = Enum.ToObject(AddressFamily, family) socktype = Enum.ToObject(ClrSocketType, socktype) proto = Enum.ToObject(ProtocolType, proto) if family == AF_UNSPEC: family = AF_INET return [(family, socktype, proto, '', (str(ip), port)) for ip in entry.AddressList]
def _getlist(it): lst = [] while it.MoveNext(): from System import Enum code = Enum.ToObject(acrx.LispDataType, it.Current.TypeCode) if code == acrx.LispDataType.ListEnd: return lst elif code == acrx.LispDataType.DottedPair: return tuple(lst) elif code == acrx.LispDataType.ListBegin: lst.append(_getlist(it)) elif code == acrx.LispDataType.T_atom: lst.append(True) elif code == acrx.LispDataType.Nil: lst.append(False) else: lst.append(it.Current.Value) return lst
def socket(family=AF_INET, type=SOCK_STREAM, proto=IPPROTO_IP): family = Enum.ToObject(AddressFamily, family) type = Enum.ToObject(ClrSocketType, type) proto = Enum.ToObject(ProtocolType, proto) socket = Socket(family, type, proto) return PythonSocket(socket)