Skip to content

Commit 45bd3a6

Browse files
committed
implement bind
1 parent b8bf37a commit 45bd3a6

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

libogc/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ add_library(ogc STATIC
99

1010
ogc_sockets/soc_common.c
1111
ogc_sockets/soc_socket.c
12+
ogc_sockets/soc_bind.c
1213

1314
console.c
1415
lwp_queue.c

libogc/ogc_sockets/soc_bind.c

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

0 commit comments

Comments
 (0)