简体   繁体   English

等效插座。 听在 python 中,在 java 中有吗?

[英]Equivalent socket. listen that there is in python , in java?

as you probably know we have socket.listen(10) that limits the number of clients inside the server and server will responsible to answer to at most 10 clients.你可能知道我们有 socket.listen(10),它限制了服务器内的客户端数量,服务器将负责回答最多 10 个客户端。 i am searching something like this in java.我正在 java 中搜索类似的内容。 Thanks.谢谢。

That parameter in Python controls the size of the backlog queue. Python 中的那个参数控制积压队列的大小。 In Java it is set with the backlog parameter in the ServerSocket constructor.在 Java 中,它是使用 ServerSocket 构造函数中的backlog参数设置的。 https://docs.oracle.com/javase/7/docs/api/java/net/ServerSocket.html#ServerSocket(int,%20int) https://docs.oracle.com/javase/7/docs/api/java/net/ServerSocket.html#ServerSocket(int,%20int)

int backlog = 10;
var ss = new ServerSocket(port, backlog);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM