diff --git a/src/libos/src/net/unix_socket.rs b/src/libos/src/net/unix_socket.rs index 5fc2808e..bfde30b1 100644 --- a/src/libos/src/net/unix_socket.rs +++ b/src/libos/src/net/unix_socket.rs @@ -184,12 +184,13 @@ enum Status { impl UnixSocket { /// C/S 1: Create a new unix socket pub fn new(socket_type: c_int, protocol: c_int) -> Result { - if socket_type == libc::SOCK_STREAM && protocol == 0 { + if socket_type == libc::SOCK_STREAM && (protocol == 0 || protocol == libc::PF_UNIX) { Ok(UnixSocket { obj: None, status: Status::None, }) } else { + // Return different error numbers according to input return_errno!(ENOSYS, "unimplemented unix socket type") } } diff --git a/test/unix_socket/main.c b/test/unix_socket/main.c index 06aff443..b41d0c71 100644 --- a/test/unix_socket/main.c +++ b/test/unix_socket/main.c @@ -34,7 +34,7 @@ int create_connected_sockets(int *sockets, char *sock_path) { THROW_ERROR("failed to listen"); } - int client_fd = socket(AF_UNIX, SOCK_STREAM, 0); + int client_fd = socket(AF_UNIX, SOCK_STREAM, PF_UNIX); if (client_fd == -1) { close(listen_fd); THROW_ERROR("failed to create a unix socket");