On Sat, Mar 10, 2018 at 10:19 AM Anto Aravinth <anto.aravinth....@gmail.com>
wrote:

> Hello all,
>
> I'm learning golang and I wanted to try out this. Wanted to make a event
> driven server using Kqueue sys call (I'm on mac). A simple echo server will
> do.
>

If you want to learn this, I suggest you start off with something like C
which the kqueue/kevent interface was built for. A Go-idiomatic solution
would usually abstract this away by means of using goroutines[0].

Also, you code seems to be missing part of the usual socket interface.
Calling net.Listen creates a Listener from which you can draw connections
through the means of Accept(). You want the file descriptors of accepted
sockets in your case I think.

In Go, an acceptor pool would usually spawn of goroutines which will then
accept on the socket and do concurrent work. Note that there are many
considerations in building a robust acceptor pool in general (and I would
wager several exist of varying levels of stability).

[0] On Mac and BSD, the interface is usually kqueue/kevent. On Linux a
completely different epoll() interface exist (which is a slightly bonkers
API IMO), and on Illumos you have event ports filling in the same problem
space.

Interestingly, systems such as Node.js is just a wrapper on top of these
eventing systems, to which you've frankensteined in a Javascript JIT on the
side. There are many limitations to such a system with regard to system
stability and latency. Especially as projects grow large.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to