Skip to content

Commit 95419ad

Browse files
committed
implement listen
1 parent 45bd3a6 commit 95419ad

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

libogc/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ add_library(ogc STATIC
1010
ogc_sockets/soc_common.c
1111
ogc_sockets/soc_socket.c
1212
ogc_sockets/soc_bind.c
13+
ogc_sockets/soc_listen.c
1314

1415
console.c
1516
lwp_queue.c

libogc/ogc_sockets/soc_listen.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include "soc_common.h"
2+
#include <errno.h>
3+
#include <sys/socket.h>
4+
5+
int listen(int sockfd, int max_connections)
6+
{
7+
sockfd = soc_get_fd(sockfd);
8+
if(sockfd < 0) {
9+
errno = -sockfd;
10+
return -1;
11+
}
12+
13+
int ret = net_listen(sockfd, max_connections);
14+
if (ret) {
15+
errno = -ret;
16+
return -1;
17+
}
18+
return 0;
19+
}

0 commit comments

Comments
 (0)