Skip to content

Instantly share code, notes, and snippets.

@Scriptor
Created February 6, 2013 22:50
Show Gist options
  • Save Scriptor/4726625 to your computer and use it in GitHub Desktop.
Save Scriptor/4726625 to your computer and use it in GitHub Desktop.
(ns stream-play)
(use pharen.io.async as io)
(let
[addr (gethostbyname "www.example.com")
client (stream_socket_client (. "tcp://" addr ":80")
errno error-msg 30
(| STREAM_CLIENT_CONNECT STREAM_CLIENT_ASYNC_CONNECT))
read (arr [client])
write (arr [client])
except NULL]
(prn (stream-select read write except 0))
(stream-set-blocking client 0)
(fwrite client "GET / HTTP/1.0\r\nHost: www.example.com\r\nAccept: */*\r\n\r\n")
(fclose client))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment