简体   繁体   English

在kryonet中,如何在不停止程序的情况下与服务器断开连接?

[英]In kryonet, how do I disconnect from a server without stopping my program?

I am trying to make a simple TCP chat program, and I want the user to be able to start the program, then be able to enter a specific ip to connect to, and then disconnect from that specific server, and then connect to another after that. 我正在尝试制作一个简单的TCP聊天程序,我希望用户能够启动该程序,然后能够输入要连接到的特定ip ,然后从该特定服务器断开连接,然后在以后连接到另一个那。

I know that the client is connected once it runs client.connect(timeout, ip, port) , but the only way I know of to disconnect the client from the server is by exiting the program. 我知道客户端一旦运行client.connect(timeout, ip, port)连接,但是我知道要将客户端与服务器断开连接的唯一方法是退出程序。

Is there any way to do this? 有什么办法吗?

You can use client.stop(); 您可以使用client.stop(); to disconnect 断开连接

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

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