-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring: Introduce extension NetNameResolver class>>#addressForSo…
…cketPath: and use it in ZnNetworkingUtils>>#unixSocketOnFile:
- Loading branch information
Sven Van Caekenberghe
committed
Sep 5, 2023
1 parent
b772d56
commit a6f7fa3
Showing
4 changed files
with
19 additions
and
17 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
...ory/Zinc-HTTP-UnixSocket.package/NetNameResolver.extension/class/addressForSocketPath..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
*Zinc-HTTP-UnixSocket | ||
addressForSocketPath: socketPath | ||
"Resolve a socketPath, a Unix Domain Socket, to a SocketAddress" | ||
|
||
| addressSize socketAddress | | ||
self initializeNetwork. | ||
self primGetAddressInfoHost: '' service: socketPath flags: 0 family: 1 type: 0 protocol: 0. | ||
addressSize := self primGetAddressInfoSize. | ||
socketAddress := SocketAddress new: addressSize withAll: 0. | ||
self primGetAddressInfoResult: socketAddress. | ||
^ socketAddress |
3 changes: 3 additions & 0 deletions
3
repository/Zinc-HTTP-UnixSocket.package/NetNameResolver.extension/properties.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"name" : "NetNameResolver" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 4 additions & 16 deletions
20
...ry/Zinc-HTTP-UnixSocket.package/ZnNetworkingUtils.extension/instance/unixSocketOnFile..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,13 @@ | ||
*Zinc-HTTP-UnixSocket | ||
unixSocketOnFile: socketFile | ||
| addressSize socketAddress ipcSocket | | ||
| socketAddress ipcSocket | | ||
socketFile exists ifFalse: [ | ||
ZnMissingUnixSocket new file: socketFile; signal ]. | ||
|
||
NetNameResolver initializeNetwork. | ||
NetNameResolver | ||
primGetAddressInfoHost: '' | ||
service: socketFile fullName | ||
flags: 0 | ||
family: 1 | ||
type: 0 | ||
protocol: 0. | ||
addressSize := NetNameResolver primGetAddressInfoSize. | ||
socketAddress := SocketAddress new: addressSize withAll: 0. | ||
NetNameResolver primGetAddressInfoResult: socketAddress. | ||
|
||
socketAddress := NetNameResolver addressForSocketPath: socketFile fullName. | ||
ipcSocket := Socket newIPC. | ||
ipcSocket ifNil: [ | ||
ZnCannotCreateUnixSocket new file: socketFile; signal ]. | ||
ZnCannotCreateUnixSocket new file: socketFile; signal ]. | ||
ipcSocket connectTo: socketAddress. | ||
ipcSocket isConnected ifFalse: [ | ||
ZnCannotConnectUnixSocket new file: socketFile; signal ]. | ||
ZnCannotConnectUnixSocket new file: socketFile; signal ]. | ||
^ ipcSocket |