|
9 | 9 | (local MODULE_INFO MSG_MAX_SIZE *Nanomsg *NN_Symbols)
|
10 | 10 | (local nn-socket nn-close nn-setsockopt nn-getsockopt nn-bind nn-connect nn-shutdown nn-send nn-recv)
|
11 | 11 | (local nn-errno nn-strerror nn-symbol nn-poll nn-device nn-poll-lt-1 fetch-symbols symbol-val)
|
12 |
| -(local exit-with-error exit-with-error-maybe make-socket sub-unsub non-blocking-io) |
| 12 | +(local exit-with-error exit-with-error-maybe make-socket make-endpoint check-endpoint sub-unsub non-blocking-io) |
13 | 13 |
|
14 | 14 | (load (pack (car (file)) "module.l"))
|
15 | 15 |
|
|
135 | 135 | (let Sock (nn-socket Domain Type)
|
136 | 136 | (if (= -1 Sock)
|
137 | 137 | (exit-with-error Sock)
|
138 |
| - (let Endpoint |
139 |
| - (cond ((= Type "NN_REP") (nn-bind Sock Addr)) |
140 |
| - ((= Type "NN_REQ") (nn-connect Sock Addr)) |
141 |
| - ((= Type "NN_PUB") (nn-bind Sock Addr)) |
142 |
| - ((= Type "NN_SUB") (nn-connect Sock Addr)) |
143 |
| - ((= Type "NN_BUS") (if (= Flag "BIND") (nn-bind Sock Addr) (nn-connect Sock Addr))) |
144 |
| - ((= Type "NN_PAIR") (if (= Flag "BIND") (nn-bind Sock Addr) (nn-connect Sock Addr))) |
145 |
| - ((= Type "NN_PULL") (nn-bind Sock Addr)) |
146 |
| - ((= Type "NN_PUSH") (nn-connect Sock Addr)) |
147 |
| - ((= Type "NN_SURVEYOR") (nn-bind Sock Addr)) |
148 |
| - ((= Type "NN_RESPONDENT") (nn-connect Sock Addr)) ) |
149 |
| - (cond ((not Endpoint) (exit-with-error Sock)) |
150 |
| - ((= -1 Endpoint) (exit-with-error Sock Endpoint)) |
151 |
| - (T (cons Sock Endpoint)) ] |
| 138 | + (let Endpoint (make-endpoint Addr Type Flag Sock) |
| 139 | + (check-endpoint Sock Endpoint) ] |
| 140 | + |
| 141 | +[de make-endpoint (Addr Type Flag Sock) |
| 142 | + (cond ((= Type "NN_REP") (nn-bind Sock Addr)) |
| 143 | + ((= Type "NN_REQ") (nn-connect Sock Addr)) |
| 144 | + ((= Type "NN_PUB") (nn-bind Sock Addr)) |
| 145 | + ((= Type "NN_SUB") (nn-connect Sock Addr)) |
| 146 | + ((= Type "NN_BUS") (if (= Flag "BIND") (nn-bind Sock Addr) (nn-connect Sock Addr))) |
| 147 | + ((= Type "NN_PAIR") (if (= Flag "BIND") (nn-bind Sock Addr) (nn-connect Sock Addr))) |
| 148 | + ((= Type "NN_PULL") (nn-bind Sock Addr)) |
| 149 | + ((= Type "NN_PUSH") (nn-connect Sock Addr)) |
| 150 | + ((= Type "NN_SURVEYOR") (nn-bind Sock Addr)) |
| 151 | + ((= Type "NN_RESPONDENT") (nn-connect Sock Addr)) ] |
| 152 | + |
| 153 | +[de check-endpoint (Sock Endpoint) |
| 154 | + (cond ((not Endpoint) (exit-with-error Sock)) |
| 155 | + ((= -1 Endpoint) (exit-with-error Sock Endpoint)) |
| 156 | + (T (cons Sock Endpoint)) ] |
152 | 157 |
|
153 | 158 | [de sub-unsub (Sock Topic Type)
|
154 | 159 | (let Result
|
|
0 commit comments