Java DatagramSocket setting keep-alive option

人走茶凉 提交于 2019-12-13 20:28:38

问题


I'm trying to create a datagramsocket with and datagrampacket to send with the keep-alive option. I'm confused about how to set this though. Is there a simple way to do it like datagramsocket.setKeepAlive(true); ?

EDIT: Sorry, I meant setting the time to live of a packet. Is there a way I can set it so if it isn't received, it will stay until it is received?


回答1:


UDP is what's called connectionless protocol, i.e. no connection is established, you just send packets to an ip address/port tuple. Since there is no connection, there is nothing to keep alive.



来源:https://stackoverflow.com/questions/9675187/java-datagramsocket-setting-keep-alive-option

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!