Skip to content

Commit a3d11ad

Browse files
committed
implement connect
1 parent ecb91bd commit a3d11ad

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

libogc/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ add_library(ogc STATIC
1313
ogc_sockets/soc_listen.c
1414
ogc_sockets/soc_send.c
1515
ogc_sockets/soc_recv.c
16+
ogc_sockets/soc_connect.c
1617

1718
console.c
1819
lwp_queue.c

libogc/ogc_sockets/soc_connect.c

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

0 commit comments

Comments
 (0)