gpt4 book ai didi

java - Python 或 Java 是否支持抽象命名空间中的 UNIX 域套接字?

转载 作者:行者123 更新时间:2023-12-03 11:50:13 25 4
gpt4 key购买 nike

Like this

abstract: an abstract socket address is distinguished by the fact that sun_path[0] is a null byte ('\0'). The socket's address in this namespace is given by the additional bytes in sun_path that are covered by the specified length of the address structure. (Null bytes in the name have no special significance.) The name has no connection with filesystem pathnames. When the address of an abstract socket is returned by getsockname(2), getpeername(2), and accept(2), the returned addrlen is greater than sizeof(sa_family_t) (i.e., greater than 2), and the name of the socket is contained in the first (addrlen - sizeof(sa_family_t)) bytes of sun_path. The abstract socket namespace is a nonportable Linux extension.

我想连接在抽象命名空间(@xxx 或\0xxx)中创建的套接字。

最佳答案

自 2006 年 2.5 版以来,Python 一直支持“Linux 抽象套接字命名空间”。

这是根据来源和变更日志得出的。 Misc/HISTORY (注意:大文件)

Patch #1062014: AF_UNIX sockets under Linux have a special abstract namespace that is now fully supported.

它没有在 Python2 文档中提及,但 在最新的文档中明确提及 Python 3 socket docs

你在Python2下试过吗?

至于Java,它甚至不直接支持AF_UNIX套接字;它需要 JNI。有许多实现(四处搜索),但您几乎肯定需要进行一些 C 开发以获得 Linux 抽象命名空间支持。

你可以试试 Jtux它是用于 Java 的完整 UNIX api 库,当然包括 AF_UNIX 套接字。

关于java - Python 或 Java 是否支持抽象命名空间中的 UNIX 域套接字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26012812/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com