EsotericSoftware / kryonet

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

Async client connect() method #143

Open MaXaMaR opened 6 years ago

MaXaMaR commented 6 years ago

Currently connect() method trashes the update thread. That makes handling multiple parallel connections troublesome. For example that may be done by separating calls to update() methods in two threads - first one handles the connecting clients and the second one handles send/recv updates. However I'm not sure how correct is it to handle all connect calls in one thread as latency was high when using single thread only (3-4s single thread vs 1-2ms two update threads). Overall it would be great if connect() was async too without all-time-polling connect-only handling thread that is always active in the profiler.

TcpConnection.java:77 socket.connect(remoteAddress, timeout); // Connect using blocking mode for simplicity.

MaXaMaR commented 6 years ago

It also postpones graceful shutdown

payne911 commented 4 years ago

@MaXaMaR About your last comment: could a postponed graceful shutdown be a possible cause for the following issue? https://github.com/EsotericSoftware/kryonet/issues/142