SuperMarioOdysseyOnline/include/nn/socket.h

63 lines
1.4 KiB
C
Raw Normal View History

2022-06-16 21:33:18 +00:00
#pragma once
#include "../types.h"
2022-09-05 10:26:14 +00:00
struct pollfd
{
s32 fd;
s16 events;
s16 revents;
};
2022-06-16 21:33:18 +00:00
struct in_addr
{
u32 data; // 0
};
struct sockaddr
{
u8 _0; // 0
u8 family; // 1
u16 port; // 2
in_addr address; // 4
u8 _8[8]; // 8
};
struct hostent
{
char* h_name;
char** h_aliases;
int h_addrtype;
int h_length;
char** h_addr_list;
};
2022-06-16 21:33:18 +00:00
namespace nn { namespace socket {
Result Initialize(void* pool, ulong poolSize, ulong allocPoolSize, int concurLimit);
s32 SetSockOpt(s32 socket, s32 socketLevel, s32 option, void const*, u32 len);
s32 Socket(s32 domain, s32 type, s32 protocol);
s32 Connect(s32 socket, const sockaddr* address, u32 addressLen);
Result Close(s32 socket);
s32 Send(s32 socket, const void* data, ulong dataLen, s32 flags);
2022-09-03 08:57:57 +00:00
s32 SendTo(s32 socket, const void* data, ulong dataLen, s32 flags, const struct sockaddr* to, u32 toLen);
2022-06-16 21:33:18 +00:00
s32 Recv(s32 socket, void* out, ulong outLen, s32 flags);
2022-09-03 08:57:57 +00:00
s32 RecvFrom(s32 socket, void* out, ulong outLen, s32 flags, struct sockaddr* from, u32* fromLen);
2022-06-16 21:33:18 +00:00
2022-09-05 10:19:33 +00:00
s32 GetSockName(s32 socket, struct sockaddr* name, u32* dataLen);
2022-06-16 21:33:18 +00:00
u16 InetHtons(u16 val);
2022-09-05 10:19:33 +00:00
u16 InetNtohs(u16 val);
2022-06-16 21:33:18 +00:00
s32 InetAton(const char* addressStr, in_addr* addressOut);
struct hostent* GetHostByName(const char* name);
2022-06-19 01:36:00 +00:00
u32 GetLastErrno();
2022-09-03 08:57:57 +00:00
s32 Bind(s32 fd, sockaddr* addr, u32 addrlen);
s32 Poll(struct pollfd* fd, u64 addr, s32 timeout);
2022-06-19 01:36:00 +00:00
2022-06-16 21:33:18 +00:00
} }