EsotericSoftware / kryonet

TCP/UDP client/server library for Java, based on Kryo
BSD 3-Clause "New" or "Revised" License
1.82k stars 419 forks source link

selector.close() in Client.java #60

Closed chechu closed 10 years ago

chechu commented 10 years ago

Hi, and thank you by the library, good job :-)

Using the client and the server in the same machine, in Linux, starting (client.start()) and stopping (client.stop()) clients iteratively, the number of open files increases constantly.

I have "resolved" the problem closing the selector associated with the client in the Client.stop() method. The problem of this solution is that the selector is created in the constructor, not in the start() method, so in Client object is not useful after the call to the stop method. I resolved this handicap creating another Client object, but I suppose that is not the best solution.

Maybe the "Selector.open()" code could be move to the start() method, too.

What do you think?

Related: https://groups.google.com/forum/#!topic/kryonet-users/hZseVPP0vfk

NathanSweet commented 10 years ago

Client#start is optional, the API allows run to be called without using start OR update to be called as needed. Selector.open shouldn't go in Client#start. I don't see another clean place to open/close the selector.

I added dispose methods to Client and Server which should be called when they are no longer needed.

-Nate

On Wed, Jan 22, 2014 at 3:11 PM, Jesus Lanchas notifications@github.comwrote:

Hi, and thank you by the library, good job :-)

Using the client and the server in the same machine, in Linux, starting (client.start()) and stopping (client.stop()) clients iteratively, the number of open files increases constantly.

I have "resolved" the problem closing the selector associated with the client in the Client.stop() method. The problem of this solution is that the selector is created in the constructor, not in the start() method, so in Client object is not useful after the call to the stop method. I resolved this handicap creating another Client object, but I suppose that is not the best solution.

Maybe the "Selector.open()" code could be move to the start() method, too.

What do you think?

Related: https://groups.google.com/forum/#!topic/kryonet-users/hZseVPP0vfk

Reply to this email directly or view it on GitHubhttps://github.com/EsotericSoftware/kryonet/issues/60 .

chechu commented 10 years ago

Thank you. The "dispose" method works great. It's all I need, so I close the issue.