2022-06-16 21:33:18 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <cstring>
|
|
|
|
#include "types.h"
|
|
|
|
#include "nn.h"
|
|
|
|
#include "sead/basis/seadNew.h"
|
|
|
|
|
|
|
|
class SocketBase {
|
|
|
|
|
|
|
|
public:
|
|
|
|
SocketBase(const char *name);
|
|
|
|
|
|
|
|
virtual nn::Result init(const char * ip, u16 port) = 0;
|
2022-07-05 19:45:22 +00:00
|
|
|
virtual bool closeSocket();
|
2022-06-16 21:33:18 +00:00
|
|
|
|
|
|
|
const char *getStateChar();
|
|
|
|
u8 getLogState();
|
2022-07-10 01:24:00 +00:00
|
|
|
s32 getFd();
|
2022-06-16 21:33:18 +00:00
|
|
|
|
|
|
|
void set_sock_flags(int flags);
|
|
|
|
|
2024-05-15 20:27:53 +00:00
|
|
|
const char* getIP() { return this->sock_ip; }
|
|
|
|
u16 getPort() { return this->port; }
|
2022-06-16 21:33:18 +00:00
|
|
|
void setName(const char *name) {strcpy(sockName, name);};
|
2022-06-19 01:36:00 +00:00
|
|
|
u32 socket_errno;
|
2022-06-16 21:33:18 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
s32 socket_log(const char* str);
|
|
|
|
s32 socket_read_char(char *out);
|
|
|
|
|
|
|
|
char sockName[0x10] = {};
|
2024-05-15 20:27:53 +00:00
|
|
|
char sock_ip[MAX_HOSTNAME_LENGTH] = {};
|
2022-06-16 21:33:18 +00:00
|
|
|
|
|
|
|
u16 port;
|
2022-06-25 00:48:33 +00:00
|
|
|
u8 socket_log_state = SOCKET_LOG_UNINITIALIZED;
|
2022-06-16 21:33:18 +00:00
|
|
|
s32 socket_log_socket;
|
2022-06-25 00:48:33 +00:00
|
|
|
|
2022-06-16 21:33:18 +00:00
|
|
|
int sock_flags;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|