/
615.txt
284 lines (196 loc) · 8.59 KB
/
615.txt
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
[11] [DFN[[RUBYB[[[UNIXドメインソケット]]]@en[UNIX domain socket]]]]は、
多くの [[UNIX]] 系システムで実装されている [[IPC]] 機構の一種です。
[REFS[
- [15] [CITE[]] ([TIME[2000-01-10 18:36:02 +09:00]] 版) <http://pubs.opengroup.org/onlinepubs/009619199/apdxo.htm>
- [14] [CITE[unix(7) - Linux manual page]] ([TIME[2015-09-09 21:15:22 +09:00]] 版) <http://man7.org/linux/man-pages/man7/unix.7.html>
-- [4] [CITE[Man page of UNIX]]
([TIME[2012-07-10 13:44:11 +09:00]] 版)
<http://linuxjm.sourceforge.jp/html/LDP_man-pages/man7/unix.7.html>
]REFS]
* API
[6] [[Socket]]
* 上位層プロトコル
[1] 様々な[[アプリケーションプロトコル]]の下位層として用いられています。
[10] [[HTTP]] での利用については、 [[HTTP接続]]を参照。
* URL
** [CODE(URI)@en[unix:]]
[5] [[URL scheme]] として [DFN[[CODE(URI)@en[[[unix:]]]]]]
が使われることがあります。
[29] [[PHP]] 3+ が実装しています。
[FIG(quote)[
[FIGCAPTION[
[2] [CITE@en[Docker basics - Docker Documentation]]
([TIME[2015-02-27 00:20:24 +09:00]] 版)
<https://docs.docker.com/articles/basics/>
]FIGCAPTION]
> unix://path/to/socket -> Unix socket located at path/to/socket
]FIG]
[FIG(quote)[
[FIGCAPTION[
[3] [CITE@en[Docker basics - Docker Documentation]]
([TIME[2015-02-27 00:20:24 +09:00]] 版)
<https://docs.docker.com/articles/basics/>
]FIGCAPTION]
> $ sudo <path to>/docker -H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock -d &
]FIG]
[FIG(quote)[
[FIGCAPTION[
[17] [CITE@en[Infinario/flask-redis-sentinel]]
([TIME[2015-09-18 15:33:39 +09:00]] 版)
<https://github.com/infinario/flask-redis-sentinel>
]FIGCAPTION]
> unix://'''[''':password''']'''@/path/to/socket.sock?db=0
]FIG]
[FIG(quote)[
[FIGCAPTION[
[30] [CITE@en[FFmpeg Protocols Documentation]]
([TIME[2017-01-22 02:22:36 +09:00]])
<https://ffmpeg.org/ffmpeg-protocols.html#unix>
]FIGCAPTION]
> Unix local socket
> The required syntax for a Unix socket URL is:
> unix://filepath
]FIG]
** [CODE(URI)@en[udg:]]
[13] [[PHP]]5以上では [[Unix domain socket]] による[[データグラム]] ([[UDP]] 相当)
を表すために [DFN[[CODE(URI)@en[[[udg:]]]]]] を使っています。
* ホストとポート
[20] 実装によっては、[[ホスト]]を [DFN[[CODE[unix/]]]]、[[ポート]]を[[ファイル名]]とすることで、
[[TCP]] ではなく [[UNIX domain socket]] での接続として扱うことがあります。
* 実装
[FIG(quote)[
[FIGCAPTION[
[7] [CITE@en[Connection String URI Format — MongoDB Manual 2.6.7]]
([TIME[2015-01-24 08:01:19 +09:00]] 版)
<http://docs.mongodb.org/manual/reference/connection-string/>
]FIGCAPTION]
> The following connects to a UNIX domain socket:
> mongodb:///tmp/mongodb-27017.sock
]FIG]
[FIG(quote)[
[FIGCAPTION[
[8] [CITE[Module ngx_http_proxy_module]]
([TIME[2015-02-26 15:57:24 +09:00]] 版)
<http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass>
]FIGCAPTION]
> or as a UNIX-domain socket path specified after the word “unix” and enclosed in colons:
> proxy_pass http://unix:/tmp/backend.socket:/uri/;
]FIG]
[FIG(quote)[
[FIGCAPTION[
[9] [CITE[AnyEvent::Socket - search.cpan.org]]
([TIME[2015-03-21 20:30:43 +09:00]] 版)
<http://search.cpan.org/dist/AnyEvent/lib/AnyEvent/Socket.pm#($service,_$host)_=_AnyEvent::Socket::unpack_sockaddr_$sa>
]FIGCAPTION]
> If the $text is unix/, then this function returns a special token recognised by the other functions in this module to mean "UNIX domain socket".
]FIG]
[FIG(quote)[
[FIGCAPTION[
[12] [CITE@en[kennethreitz/dj-database-url]]
([TIME[2015-07-09 00:48:26 +09:00]] 版)
<https://github.com/kennethreitz/dj-database-url>
]FIGCAPTION]
> With PostgreSQL, you can also use unix domain socket paths with percent encoding: postgres://%2Fvar%2Flib%2Fpostgresql/dbname.
]FIG]
[FIG(quote)[
[FIGCAPTION[
[16] [CITE[Using Redis — Celery 3.1.18 documentation]]
([TIME[2015-09-10 03:56:21 +09:00]] 版)
<http://celery.readthedocs.org/en/latest/getting-started/brokers/redis.html>
]FIGCAPTION]
> If a unix socket connection should be used, the URL needs to be in the format:
> redis+socket:///path/to/redis.sock
]FIG]
[18] [CITE[Issue 376323002: Refactor unix domain socket. - Code Review]]
([TIME[2015-09-22 18:14:15 +09:00]] 版)
<https://codereview.chromium.org/376323002/>
[FIG(quote)[
[FIGCAPTION[
[19] [CITE[cURL - How To Use]]
( ([TIME[2016-05-31 06:05:05 +09:00]]))
<https://curl.haxx.se/docs/manpage.html#--unix-socket>
]FIGCAPTION]
> --unix-socket <path>
> (HTTP) Connect through this Unix domain socket, instead of using the network. (Added in 7.40.0)
]FIG]
[FIG(quote)[
[FIGCAPTION[
[21] [CITE@en[Connection String URI Format — MongoDB Manual 3.2]]
([TIME[2016-10-28 23:53:37 +09:00]])
<https://docs.mongodb.com/manual/reference/connection-string/>
]FIGCAPTION]
> The following connects to a UNIX domain socket:
> mongodb:///tmp/mongodb-27017.sock
]FIG]
[FIG(quote)[
[FIGCAPTION[
[22] [CITE@en[MySQL — SQLAlchemy 0.9 Documentation]]
([TIME[2016-11-05 07:07:26 +09:00]])
<http://docs.sqlalchemy.org/en/rel_0_9/dialects/mysql.html>
]FIGCAPTION]
> mysql+mysqldb://root@/<dbname>?unix_socket=/cloudsql/<projectid>:<instancename>
]FIG]
[FIG(quote)[
[FIGCAPTION[
[23] [CITE[java - JDBC MySQL connection using Unix Socket - Stack Overflow]]
([TIME[2016-11-17 23:47:34 +09:00]])
<http://stackoverflow.com/questions/25918416/jdbc-mysql-connection-using-unix-socket>
]FIGCAPTION]
> As another answer pointed out, it's possible (at least in Intellij IDE) to use socket connection for Mysql JDBC Connector/J (I am using version 5.1) without having to provide a socketFactory,
> jdbc:mysql://localhost:3306/database_name?socket=/tmp/mysql.sock
]FIG]
[FIG(quote)[
[FIGCAPTION[
[24] [CITE[java - JDBC MySQL connection using Unix Socket - Stack Overflow]]
([TIME[2016-11-17 23:47:57 +09:00]])
<http://stackoverflow.com/questions/25918416/jdbc-mysql-connection-using-unix-socket>
]FIGCAPTION]
> The JDBC Driver from the MariaDB project supports Unix domain sockets while remaining compatible with the MySQL Connector/J JDBC driver. Example jdbc url for the MariaDB driver is: jdbc:mariadb://localhost:3306/revmgt?localSocket=/var/run/mysqld/mysqld.sock
]FIG]
[FIG(quote)[
[FIGCAPTION[
[25] [CITE[The DB-URI — TurboGears 1.0 documentation]]
([TIME[2013-01-12 16:52:59 +09:00]])
<http://turbogears.org/1.0/docs/DbUri.html>
]FIGCAPTION]
> mysql://localhost/database?unix_socket=/var/lib/mysql/socket
]FIG]
[FIG(quote)[
[FIGCAPTION[
[26] [CITE[The DB-URI — TurboGears 1.0 documentation]]
([TIME[2013-01-12 16:52:59 +09:00]])
<http://turbogears.org/1.0/docs/DbUri.html>
]FIGCAPTION]
> If your Linux or OS X installation has a standard setup and there’s a live socket at /tmp/.s.PGSQL.5432, your SQLAlchemy PostgreSQL dburi can be this simple:
> postgres:///dbname
> To specify the socket file for PostgreSQL, put the absolute path after the double slash:
> postgres:///var/run/postgresql/test?debug=1
> However, there are bugs in the DSN parser for SQLObject, so that it fails to separate the socket path from the database name. A DSN like this works around that issue:
> postgres:///dbname?host=/path/to/socket
]FIG]
[FIG(quote)[
[FIGCAPTION[
[27] [CITE[nova.conf - configuration options - OpenStack Configuration Reference - kilo]]
([TIME[2016-05-10 16:38:51 +09:00]])
<http://docs.openstack.org/kilo/config-reference/content/list-of-compute-config-options.html>
]FIGCAPTION]
> connection_url = None (StrOpt) URL for connection to XenServer/Xen Cloud Platform. A special value of unix://local can be used to connect to the local unix socket. Required if compute_driver=xenapi.XenAPIDriver
]FIG]
[FIG(quote)[
[FIGCAPTION[
[28] [CITE@en[Linknx / Wiki / Services_section]]
([TIME[2016-11-18 00:10:58 +09:00]])
<https://sourceforge.net/p/linknx/wiki/Services_section/>
]FIGCAPTION]
> The knxconnection element configures the connection to EIBD. The url parameter can be "local:/path/to/unix/socket" if EIBD uses unix sockets or "ip:ip-address:port" if EIBD uses internet sockets (port is optional; default = 6720)
]FIG]
[FIG(quote)[
[FIGCAPTION[
[31] [CITE@en[Compose CLI environment variables | Docker Documentation]]
( ([TIME[2017-06-10 02:19:31 +09:00]]))
<https://docs.docker.com/compose/reference/envvars/>
]FIGCAPTION]
> DOCKER_HOST
> Sets the URL of the docker daemon. As with the Docker client, defaults to unix:///var/run/docker.sock.
]FIG]
[32] [CODE[http+docker://localunixsocket]]