-
Notifications
You must be signed in to change notification settings - Fork 0
/
FixedPathTcpSocketFactory.clj
39 lines (33 loc) · 1.18 KB
/
FixedPathTcpSocketFactory.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
(ns unixsocket-http.impl.FixedPathTcpSocketFactory
"SocketFactory that produces `FixedPathTcpSocket` objects bound to a fixed path."
(:gen-class
:name unixsocket_http.impl.FixedPathTcpSocketFactory
:extends javax.net.SocketFactory
:init init
:state state
:constructors {[String Integer] []})
(:require [clojure.java.io :as io])
(:import [unixsocket_http.impl FixedPathTcpSocket]
[java.net InetAddress]
[java.net InetSocketAddress Socket SocketAddress]
[javax.net SocketFactory]))
;; ## Constructor
(defn -init
[^String host ^Integer port]
[[] (InetSocketAddress. host port)])
;; ## Methods
(defn- create-socket!
^FixedPathTcpSocket [^unixsocket_http.impl.FixedPathTcpSocketFactory this]
(FixedPathTcpSocket. ^SocketAddress (.-state this)))
(defn -createSocket
([this]
(create-socket! this))
([this ^InetAddress _ ^Integer _]
(doto (create-socket! this)
(.connect)))
([this ^InetAddress _ ^Integer _ ^InetAddress _ ^Integer _]
(doto (create-socket! this)
(.connect))))
(defn -toString
[^unixsocket_http.impl.FixedPathTcpSocketFactory this]
(str (.-state this)))