Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IOLib vs usocket

In my understanding, IOLib and usocket have almost same abstraction level. IOLib uses OS-backend sockets, on the other hand usocket uses Lisp-runtime-backend socket.

I just wonder which is a better choice for particular use cases.

For example, a server which needs great concurrency, or a client which focuses on portability, etc.

like image 573
Takayuki Sato Avatar asked Nov 22 '12 10:11

Takayuki Sato


3 Answers

I think, this blogpost answers your question.

To sum up, if you're writing a library, which should work on all platforms and implementations (with a reasonable definition of "all"), use usocket. For other use-cases on the Unix platform, IOLib is probably more versatile. For example, it supports Unix domain sockets, as well as non-blocking IO.

By the way, I had ported cl-redis from usocket to IOLib and back - the API is very similar, although slightly different.

like image 198
Vsevolod Dyomkin Avatar answered Nov 09 '22 14:11

Vsevolod Dyomkin


The code for USOCKET is much smaller and simpler than IOLib including dependencies. IOLib uses CFFI bindings to Linux features which are not present in some *BSD for example.

All other things being equal, minimal source code is always preferable because it means less bugs, because it is easier to understand and hack. Simpler code is faster to debug, and deploys more easily.

Other than that, they both seem to work roughly the same : they both provide kqueue/select to handle multiple connections within a single thread. I'm not sure about more advanced functions, like passing a unix file descriptor in a socket.

I'd say if you only like Linux, go with IOLib or USOCKET, if you target Linux and/or *BSD, or other commercial operating systems, or like to Keep It Simple & Stupid, go with USOCKET.

like image 20
thodg Avatar answered Nov 09 '22 14:11

thodg


If your main goal is portability, apparently usockets is better choice, since as it's stated on this page:

USOCKET is a networking portability layer for BSD-style sockets.

like image 1
Oleksandr Kravchuk Avatar answered Nov 09 '22 16:11

Oleksandr Kravchuk