How can I implement an AsyncSocket in java (specificaly on android)?
Asked
Active
Viewed 1,363 times
4
-
you mean something like, http://code.google.com/p/cocoaasyncsocket/ ? – sbridges Apr 30 '11 at 14:43
-
@sbridges yes! I have used this library successfully in an iphone app. – Alex1987 Apr 30 '11 at 14:51
1 Answers
1
If you want to do non blocking io in java without having 1 or more threads per socket, you have to use the java NIO libraries. There are some wrappers around NIO that make it easier to use, netty is a good example.

sbridges
- 24,960
- 4
- 64
- 71
-
I'll look into it. Too bad there is no simple solution for it in java. – Alex1987 Apr 30 '11 at 17:25
-
@Alex1987: It's a complex problem. You can't express it simply. NB NIO is not Async as conventionally understood, i.e. where the operation continues in parallel and you get a completion notification: it is non-blocking, meaning that only the part of the operation that can be completed without blocking, e.g. to/from the socket buffers, actually occurs. Not the same thing. IBM had an implementation of async sockets at one time but it was bound to Windows. – user207421 May 01 '11 at 04:36