I read elisp’s network server manul, but I cann’t find write a socket listening server. Some puzzles of the function “make-network-process”:
- How to bind the server?
- How to accept the client connections and create a a new network process?
- how to communicat with the client process by the new created network process?
Is there any snippet source code about network server?
make-network-processwill make a listening server, binding it to the given port. For that, you just need to specify:server tamong the keyword arguments.Client connections will automatically be accepted and will automatically create new network processes. Elisp code can set things up when a new connection comes in, because the
process-sentinelfunction gets called when this happens.Communication with the client happens via network-process created when the client connection was accepted. This process will be used like any other process, i.e. via
process-filter,process-send-string, …You can look at the
server.elcode (C-h f server-startshould be a good entry point) for a reasonably simple example.