Search code examples
javatcpnetwork-programmingdisconnectkryonet

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.

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.

Is there any way to do this?


Solution

  • You can use client.stop(); to disconnect