In Golang, if we want to write a socket server, we can write like this :
listen, err := net.Listen("tcp", "****")
for {
conn, err := listen.Accept()
...
}
net.Listen()
include create socket
, bind
, listen
, and uses epoll
in implementation.
in CPP, if we want to write a server, we can chose to use select
, poll
or epoll
freely , so my question is: in Golang, how can I write a server using select
or poll
instead of `epoll.
CodePudding user response:
If you are familiar with system calls used during connection creation; you will find the syscalls package useful for what you need to do where you can choose to use these system calls as you need. It consists of all the system calls you will need.
I also found this example gist which you can reference for making your own implementation using poll or select.