This repository has been archived on 2024-06-18. You can view files and clone it, but cannot push or open issues/pull-requests.
2019-07-27 15:29:27 +02:00
|
|
|
|
2020-07-13 14:17:29 +02:00
|
|
|
class IPC::Client < IPC::Context
|
2020-07-13 18:40:21 +02:00
|
|
|
property server_fd : Int32
|
|
|
|
|
2020-07-13 14:17:29 +02:00
|
|
|
# By default, this is a client.
|
|
|
|
def initialize(service_name : String)
|
2019-07-27 15:29:27 +02:00
|
|
|
super()
|
2020-07-13 18:40:21 +02:00
|
|
|
serverfd = 0
|
|
|
|
|
|
|
|
r = LibIPC.ipc_connection(self.pointer, service_name, pointerof(serverfd))
|
2020-07-13 14:17:29 +02:00
|
|
|
if r.error_code != 0
|
|
|
|
m = String.new r.error_message.to_slice
|
|
|
|
raise Exception.new "error during connection establishment: #{m}"
|
|
|
|
end
|
|
|
|
|
2020-07-13 18:40:21 +02:00
|
|
|
@server_fd = server_fd
|
|
|
|
|
2020-07-13 14:17:29 +02:00
|
|
|
# Very important as there are filesystem side-effects.
|
|
|
|
at_exit { close }
|
2019-07-27 15:29:27 +02:00
|
|
|
end
|
|
|
|
end
|