mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
socket: add msghdr to header and fix backlog issue
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#ifndef _SOCKET_H_INCLUDE
|
||||
#define _SOCKET_H_INCLUDE
|
||||
|
||||
#include <kernel/fd.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
@@ -18,6 +20,15 @@
|
||||
#define AF_UNIX 1
|
||||
|
||||
typedef unsigned socklen_t;
|
||||
typedef struct {
|
||||
void *msg_name;
|
||||
socklen_t msg_namelen;
|
||||
struct iovec *msg_iov;
|
||||
size_t msg_iovlen;
|
||||
void *msg_control;
|
||||
size_t msg_controllen;
|
||||
int msg_flags;
|
||||
} msghdr;
|
||||
|
||||
typedef struct _socket_t{
|
||||
int lock;
|
||||
@@ -56,15 +67,15 @@ static inline socket_t* socket_popfrombacklog(socket_t* listener){
|
||||
|
||||
memcpy(listener->backlog, listener->backlog+1, sizeof(socket_t*)*listener->backlogend);
|
||||
|
||||
listener->backlog[listener->backlogend];
|
||||
listener->backlog[listener->backlogend] = NULL;
|
||||
|
||||
return sock;
|
||||
}
|
||||
|
||||
int socket_connect(struct _socket_t* sock, void* addr, socklen_t addrlen);
|
||||
int socket_connect(struct _socket_t* sock, void* addr, socklen_t addrlen, fd_t* fd);
|
||||
int socket_new(socket_t** returnptr, int family, int type, int protocol);
|
||||
int socket_bind(struct _socket_t* sock, void* addr, socklen_t addrlen);
|
||||
int socket_listen(struct _socket_t* sock, int backlog);
|
||||
int socket_accept(socket_t** peer, socket_t* sock, void* addr, socklen_t* addrlen);
|
||||
int socket_send(socket_t* socket, void* buff, socklen_t len, int flags, int* error);
|
||||
int socket_accept(socket_t** peer, socket_t* sock, void* addr, socklen_t* addrlen, fd_t* fd);
|
||||
int socket_send(socket_t* socket, void* buff, size_t len, int flags, int* error, fd_t* fd);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user