chickadee » websockets » with-websocket

with-websocket #!optional procedureprocedure

with-websocket handles the process of setting up and closing off a websocket connection. procedure is a thunk to be executed after the websocket has been successfully setup. When you use with-websocket you can be assured that the connection will always be closed correctly even if errors occur in your application code and for all protocol violations.

with-websocket sends and receives all messages in a blocking fashion. Only one message will be sent or received at a time unless more threads are introduced in procedure. Even then the processing will block sending and receiving whereas it will not with with-concurrent-websocket.

Unless you expect a high volume of messages or messages of very large size on one websocket connection then this is the recommended procedure to use. It is easier to program when you know messages will arrive in order and it is more lightweight.