简体   繁体   English

没有客户端的服务器侦听端口Java

[英]Server without Clients listening to a port java

I am looking for a way to have a basic Java Server listen to a port without having any clients connected. 我正在寻找一种使基本Java Server在不连接任何客户端的情况下侦听端口的方法。 Essentially, I need to be listening on this port for any data, then output it on the server side to see that it actually works. 本质上,我需要在此端口上侦听任何数据,然后在服务器端将其输出以查看其实际工作。 As there are multiple ways to implement Java App servers, I am not sure which would be the best. 由于有多种实现Java App服务器的方法,因此我不确定哪种方法最好。

Current thought flow: A client is able to connect to a server socket because the server is listening for a connection. 当前的思想流程:客户端能够连接到服务器套接字,因为服务器正在侦听连接。 Can it be so that it can be changed to listen to data? 可以将其更改为侦听数据吗? Instead of a client socket connection? 而不是客户端套接字连接?

Code can be provided if needed but I just used a basic server example found online (using sockets). 如果需要,可以提供代码,但是我只是使用了一个在线找到的基本服务器示例(使用套接字)。

开始接收数据之前,必须在服务器和客户端套接字之间建立连接。

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

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