File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -204,11 +204,11 @@ pub const WSClient = struct {
204204
205205 mutex : std.Thread.Mutex ,
206206
207- pub fn init (allocator : Allocator , stream : net.Stream ) WSClient {
207+ pub fn init (allocator : Allocator , stream : net.Stream ) ! WSClient {
208208 return .{
209209 .allocator = allocator ,
210210 .stream = stream ,
211- .address = stream .address catch unreachable ,
211+ .address = try stream .address ,
212212 .connected = true ,
213213 .mutex = std.Thread.Mutex {},
214214 };
@@ -370,7 +370,12 @@ pub const WSServer = struct {
370370 stream .close ();
371371 continue ;
372372 };
373- client_ptr .* = WSClient .init (server .allocator , stream );
373+ client_ptr .* = WSClient .init (server .allocator , stream ) catch | err | {
374+ stdout .print ("Failed to get client address: {}\n " , .{err }) catch {};
375+ server .allocator .destroy (client_ptr );
376+ stream .close ();
377+ continue ;
378+ };
374379
375380 server .mutex .lock ();
376381 server .clients .append (server .allocator , client_ptr ) catch {
You can’t perform that action at this time.
0 commit comments