Skip to content

Commit

Permalink
std.net.Server changes
Browse files Browse the repository at this point in the history
  • Loading branch information
malcolmstill committed Mar 4, 2024
1 parent d7ffc23 commit 6da6278
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/client.zig
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub const wl = @import("wl/protocols.zig").Wayland(.{
pub const Client = struct {
server: *Server,
alloc: mem.Allocator,
conn: net.StreamServer.Connection,
conn: net.Server.Connection,
wire: wl.Wire,
serial: u32 = 0,
server_id: u32 = 0xFF00_0000 - 1,
Expand Down Expand Up @@ -88,7 +88,7 @@ pub const Client = struct {

const Self = @This();

pub fn init(alloc: mem.Allocator, server: *Server, conn: net.StreamServer.Connection, wl_display: wl.WlDisplay) Client {
pub fn init(alloc: mem.Allocator, server: *Server, conn: net.Server.Connection, wl_display: wl.WlDisplay) Client {
return .{
.alloc = alloc,
.server = server,
Expand Down
2 changes: 1 addition & 1 deletion src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn main() !void {
var server = try Server.init(allocator);
defer server.deinit();

try epoll.addFd(server.server.sockfd.?, Target{ .server = &server });
try epoll.addFd(server.server.stream.handle, Target{ .server = &server });

var backend = try Backend.init(allocator, .x11);
defer backend.deinit();
Expand Down
14 changes: 7 additions & 7 deletions src/server.zig
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const log = std.log.scoped(.server);

pub const Server = struct {
alloc: mem.Allocator,
server: std.net.StreamServer,
server: std.net.Server,
// per-server resources:
clients: IterablePool(Client, u8),
outputs: IterablePool(Output, u5),
Expand Down Expand Up @@ -95,7 +95,7 @@ pub const Server = struct {
};

pub const ServerEvent = union(EventType) {
client_connected: std.net.StreamServer.Connection,
client_connected: std.net.Server.Connection,
};

pub fn init(alloc: mem.Allocator) !Server {
Expand All @@ -116,7 +116,7 @@ pub const Server = struct {
}

pub fn deinit(server: *Self) void {
server.server.close();
server.server.stream.close();

server.clients.deinit();
server.windows.deinit();
Expand All @@ -140,7 +140,7 @@ pub const Server = struct {
std.debug.print("---------------\n", .{});
}

pub fn addClient(server: *Self, conn: std.net.StreamServer.Connection) !*Client {
pub fn addClient(server: *Self, conn: std.net.Server.Connection) !*Client {
var client = try server.clients.createPtr();
errdefer server.clients.destroy(client);

Expand Down Expand Up @@ -278,12 +278,12 @@ pub const Server = struct {
};
};

fn socket() !std.net.StreamServer {
fn socket() !std.net.Server {
_ = std.os.unlink("/run/user/1000/wayland-1") catch {};
const addr = try std.net.Address.initUnix("/run/user/1000/wayland-1");

var server = std.net.StreamServer.init(.{});
try server.listen(addr);
// var server = std.net.Server.init(.{});
const server = try addr.listen(.{});

return server;
}

0 comments on commit 6da6278

Please sign in to comment.