Java - 如何提及协议族?

时间:2022-09-24 23:58:29

In C, protocol family is mentioned as first parameter.

在C中,提到协议族作为第一个参数。

For ex:

socket(AF_INET,,) for ipv4

用于ipv4的套接字(AF_INET ,,)

socket(AF_PACKET,,) used for packet sniffing

socket(AF_PACKET ,,)用于数据包嗅探


Python supports three address families, AF_INET, AF_INET6 & AF_UNIX

Python支持三个地址族AF_INET,AF_INET6和AF_UNIX


In Java, below syntax does not allow mentioning protocol family,

在Java中,以下语法不允许提及协议族,

ServerSocket()
ServerSocket(int port)
ServerSocket(int port, int backlog)
ServerSocket(int port, int backlog, InetAddress bindAddr)

Socket()
Socket(InetAddress address, int port)
Socket(InetAddress address, int port, InetAddress localAddr, int localPort)
Socket(Proxy proxy)
Socket(SocketImpl impl)
Socket(String host, int port)
Socket(String host, int port, InetAddress localAddr, int localPort)

1) On which protocol family stack, does Java enable socket communication?

1)在哪个协议族堆栈上,Java是否支持套接字通信?

2) Does Java allow explicit mentioning of protocol family for socket communication?

2)Java是否允许明确提及套接字通信的协议族?

1 个解决方案

#1


2  

Java does not support AF_UNIX or AF_PACKET at all. All the socket classes support AF_INET and AF_INET6 only, and do so automatically depending on whether an AF_INET6 stack exists or not.

Java根本不支持AF_UNIX或AF_PACKET。所有套接字类仅支持AF_INET和AF_INET6,并根据AF_INET6堆栈是否存在自动执行。

#1


2  

Java does not support AF_UNIX or AF_PACKET at all. All the socket classes support AF_INET and AF_INET6 only, and do so automatically depending on whether an AF_INET6 stack exists or not.

Java根本不支持AF_UNIX或AF_PACKET。所有套接字类仅支持AF_INET和AF_INET6,并根据AF_INET6堆栈是否存在自动执行。