嵌入式Python-[[u socket获取模块方法,但socket.py:缺少方法] Python 2.7嵌入果酱C++中间件 我已经用MalMaldC++中间件(ARM GCC)将Python 2.7嵌入到我的移动程序中。 我可以运行大多数标准模块和第三方库 (这里有消息来源:) (修复后,我将上载更改) (此处的模块属性转储脚本:)
当我尝试导入socket.py时(确保不在主目录中运行) 它说_socket缺少以下方法: 插座:嵌入式Python-[[u socket获取模块方法,但socket.py:缺少方法] Python 2.7嵌入果酱C++中间件 我已经用MalMaldC++中间件(ARM GCC)将Python 2.7嵌入到我的移动程序中。 我可以运行大多数标准模块和第三方库 (这里有消息来源:) (修复后,我将上载更改) (此处的模块属性转储脚本:),c++,sockets,google-app-engine,python-2.7,marmalade,C++,Sockets,Google App Engine,Python 2.7,Marmalade,当我尝试导入socket.py时(确保不在主目录中运行) 它说_socket缺少以下方法: 插座: 编辑::这里有一个链接,用于比较普通套接字属性和我编译的套接字版本: 编辑我已经从socket.py中分离出抛出错误的函数(我减去getpeername来检查所有其他函数,它们很好): =输出(减去“getpeername”方法) 添加了getpeername,这是唯一一个有问题的 >>> import _socket >>> print(getattr
编辑::这里有一个链接,用于比较普通套接字属性和我编译的套接字版本:
编辑我已经从socket.py中分离出抛出错误的函数(我减去getpeername来检查所有其他函数,它们很好): =输出(减去“getpeername”方法)
添加了getpeername,这是唯一一个有问题的
>>> import _socket
>>> print(getattr(_socket.socket,'getpeername').__doc__)
AttributeError: type object '_socket.socket' has no attribute 'getpeername'
思想?
- 这还会是python路径问题吗
- c中的setenv++
- 另一个缺失的依赖模块?(还包括选择Module.c)
- 因为编译后的模块也嵌入到包含enterpreter的库中,并且没有文件。我需要修改socket.py
- getaddrinfo.c有问题吗?getnameinfo.c?>>socketmodule.c有问题吗
我加载了错误的最小裸pyconfig,它没有包括其他模块的设置。。。。然而,他们中的大多数人并没有做到这一点。W> 解决
>>> import _socket
>>> print (os.path.dirname(_socket.__file__))
AttributeError: 'module' object has no attribute '__file__'
>>> print (dir("_socket"))
['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__getslice__', '__gt__', '__hash__', '__init__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '_formatter_field_name_split', '_formatter_parser', 'capitalize', 'center', 'count', 'decode', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
>>> dumpMod.dumpObj(_socket)
Documentation string: """Implementation module for socket operations. See
the socket module for documentation."""
Built-in Methods: fromfd, getaddrinfo, getdefaulttimeout, gethostbyaddr
gethostbyname, gethostbyname_ex, gethostname
getnameinfo, getprotobyname, getservbyname
getservbyport, htonl, htons, inet_aton, inet_ntoa
inet_ntop, inet_pton, ntohl, ntohs, setdefaulttimeout
__name__ _socket
__package__ None
import _socket
_socketmethods = (
'bind', 'connect', 'connect_ex', 'fileno', 'listen', 'getsockname','getsockopt','setsockopt','sendall', 'setblocking','settimeout', 'gettimeout', 'shutdown')
for _m in _socketmethods:
print(getattr(_socket.socket,_m).__doc__)
bind(address)
Bind the socket to a local address. For IP sockets, the address is a
pair (host, port); the host must refer to the local host. For raw packet
sockets the address is a tuple (ifname, proto [,pkttype [,hatype]])
connect(address)
Connect the socket to a remote address. For IP sockets, the address
is a pair (host, port).
connect_ex(address) -> errno
This is like connect(address), but returns an error code (the errno value)
instead of raising an exception when an error occurs.
fileno() -> integer
Return the integer file descriptor of the socket.
listen(backlog)
Enable a server to accept connections. The backlog argument must be at
least 1; it specifies the number of unaccepted connection that the system
will allow before refusing new connections.
getsockname() -> address info
Return the address of the local endpoint. For IP sockets, the address
info is a pair (hostaddr, port).
getsockopt(level, option[, buffersize]) -> value
Get a socket option. See the Unix manual for level and option.
If a nonzero buffersize argument is given, the return value is a
string of that length; otherwise it is an integer.
setsockopt(level, option, value)
Set a socket option. See the Unix manual for level and option.
The value argument can either be an integer or a string.
sendall(data[, flags])
Send a data string to the socket. For the optional flags
argument, see the Unix manual. This calls send() repeatedly
until all data is sent. If an error occurs, it's impossible
to tell how much data has been sent.
setblocking(flag)
Set the socket to blocking (flag is true) or non-blocking (false).
setblocking(True) is equivalent to settimeout(None);
setblocking(False) is equivalent to settimeout(0.0).
settimeout(timeout)
Set a timeout on socket operations. 'timeout' can be a float,
giving in seconds, or None. Setting a timeout of None disables
the timeout feature and is equivalent to setblocking(1).
Setting a timeout of zero is the same as setblocking(0).
gettimeout() -> timeout
Returns the timeout in floating seconds associated with socket
operations. A timeout of None indicates that timeouts on socket
operations are disabled.
shutdown(flag)
Shut down the reading side of the socket (flag == SHUT_RD), the writing side
of the socket (flag == SHUT_WR), or both ends (flag == SHUT_RDWR).
>>> import _socket
>>> print(getattr(_socket.socket,'getpeername').__doc__)
AttributeError: type object '_socket.socket' has no attribute 'getpeername'
/* Define to 1 if you have the `getpeername' function. */
//#undef HAVE_GETPEERNAME
/* Define to 1 if you have the `gethostbyname' function. */
//#undef HAVE_GETHOSTBYNAME
/* SOCKETS FUNCTION */
#define HAVE_GETPEERNAME 1
#define HAVE_GETHOSTBYNAME 1