Liking cljdoc? Tell your friends :D

sockets

Build StatusDependencies StatusClojars ProjectTagClojure version

A Clojure wrapper for the family of Java Socket classes

Contents

Documentation

Examples

For running examples, be sure to look in the examples directory. The servers can be run with the following:

$ lein run -m examples.udp.echo-server.server

and

$ lein run -m examples.udp.quote-server.server

You can use nc (netcat) to connect to these:

$ nc -u localhost 15099

In addition, the quote server example has a client:

$ lein run -m examples.udp.quote-server.client

Usage

The following were taken from the examples mentioned above; for the full context, please see that code.

Creating a datagram socket:

(require '[sockets.datagram.socket :as socket])

(def sock (socket/create))

Creating a datagram packet implicitly with receive:

(def pkt (socket/receive sock 256))

Using the update methods with a threading macro:

(require '[inet.address :as inet]
         '[sockets.datagram.packet :as packet])

(socket/send sock
             (-> (packet/create 1)
                 (packet/update-address (inet/create [127 0 0 1]))
                 (packet/update-port port)))

License

Copyright © 2017 BilloSystems, Ltd. Co.

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close