@@ -37,7 +37,8 @@ class UNIXServer < UNIXSocket
37
37
# ```
38
38
#
39
39
# [Only the stream type is supported on Windows](https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/#unsupportedunavailable).
40
- def initialize (@path : String , type : Type = Type ::STREAM , backlog : Int = 128 )
40
+ def initialize (path : Path | String , type : Type = Type ::STREAM , backlog : Int = 128 )
41
+ @path = path = path.to_s
41
42
super (Family ::UNIX , type )
42
43
43
44
system_bind(UNIXAddress .new(path), path) do |error |
@@ -53,15 +54,16 @@ class UNIXServer < UNIXSocket
53
54
end
54
55
55
56
# Creates a UNIXServer from an already configured raw file descriptor
56
- def initialize (* , fd : Handle , type : Type = Type ::STREAM , @path : String ? = nil )
57
- super (fd: fd, type: type , path: @path )
57
+ def initialize (* , fd : Handle , type : Type = Type ::STREAM , path : Path | String ? = nil )
58
+ @path = path = path.to_s
59
+ super (fd: fd, type: type , path: path)
58
60
end
59
61
60
62
# Creates a new UNIX server and yields it to the block. Eventually closes the
61
63
# server socket when the block returns.
62
64
#
63
65
# Returns the value of the block.
64
- def self.open (path, type : Type = Type ::STREAM , backlog = 128 , & )
66
+ def self.open (path : Path | String , type : Type = Type ::STREAM , backlog = 128 , & )
65
67
server = new(path, type , backlog)
66
68
begin
67
69
yield server
0 commit comments