[英](How) can I use ServerSocket to listen for UDP instead of TCP traffic?
In my application, there's a module that uses ServerSocket
to listen for incoming TCP connections. 在我的应用程序中,有一个模块使用
ServerSocket
来侦听传入的TCP连接。 When I switched a client to use UDP, I expected to receive data anyway, but I was wrong. 当我切换客户端使用UDP时,我希望无论如何都会收到数据,但我错了。 When I looked at the documentation, however, I couldn't find any config option to set up the socket for UDP.
但是,当我查看文档时,我找不到任何配置选项来设置UDP的套接字。 Do I have to use a different class?
我必须使用不同的课程吗?
Use DatagramSocket. 使用DatagramSocket。 For a tutorial, look here http://download.oracle.com/javase/tutorial/networking/datagrams/index.html
有关教程,请查看http://download.oracle.com/javase/tutorial/networking/datagrams/index.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.