Skip to content

Commit a89bcf6

Browse files
committed
net_socket: implement SOCK_NONBLOCK
1 parent 079be0b commit a89bcf6

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

libogc/network_wii.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,8 @@ struct hostent * net_gethostbyname(const char *addrString)
696696
return ipData;
697697
}
698698

699+
#define FLAG_MASK (SOCK_NONBLOCK | SOCK_CLOEXEC)
700+
699701
s32 net_socket(u32 domain, u32 type, u32 protocol)
700702
{
701703
s32 ret;
@@ -704,12 +706,18 @@ s32 net_socket(u32 domain, u32 type, u32 protocol)
704706
if (net_ip_top_fd < 0) return -ENXIO;
705707

706708
params[0] = domain;
707-
params[1] = type;
709+
params[1] = type & ~FLAG_MASK;
708710
params[2] = protocol;
709711

710712
ret = _net_convert_error(IOS_Ioctl(net_ip_top_fd, IOCTL_SO_SOCKET, params, 12, NULL, 0));
711713
if(ret>=0) // set tcp window size to 32kb
712714
{
715+
if (type & SOCK_NONBLOCK)
716+
{
717+
int flags = net_fcntl(ret, F_GETFL, 0);
718+
flags |= IOS_O_NONBLOCK;
719+
net_fcntl(ret, F_SETFL, flags);
720+
}
713721
int window_size = 32768;
714722
net_setsockopt(ret, SOL_SOCKET, SO_RCVBUF, (char *) &window_size, sizeof(window_size));
715723
}

0 commit comments

Comments
 (0)