SuperMarioOdysseyOnline/include/server/SocketClient.hpp

51 lines
1.3 KiB
C++
Raw Normal View History

2022-06-16 21:33:18 +00:00
#pragma once
#include "SocketBase.hpp"
#include "nn/result.h"
#include "sead/math/seadVector.h"
#include "sead/math/seadQuat.h"
#include "sead/container/seadPtrArray.h"
#include "al/util.hpp"
#include "nn/account.h"
#include "syssocket/sockdefines.h"
#include "types.h"
#include "packets/Packet.h"
class SocketClient : public SocketBase {
public:
SocketClient(const char *name) : SocketBase(name) {
mPacketQueue = sead::PtrArray<Packet>();
mPacketQueue.tryAllocBuffer(maxBufSize, nullptr);
};
nn::Result init(const char* ip, u16 port) override;
bool closeSocket() override;
2022-06-16 21:33:18 +00:00
bool SEND(Packet *packet);
bool RECV();
void printPacket(Packet* packet);
bool isConnected() {return socket_log_state == SOCKET_LOG_CONNECTED; }
2022-09-03 08:57:57 +00:00
u16 getUdpPort();
2022-09-05 10:19:33 +00:00
s32 setPeerUdpPort(u16 port);
2022-06-16 21:33:18 +00:00
sead::PtrArray<Packet> mPacketQueue;
private:
int maxBufSize = 100;
2022-09-03 08:57:57 +00:00
s32 udp_socket;
sockaddr udp_addr;
2022-08-30 22:18:44 +00:00
/**
* @param str a string containing an IPv4 address or a hostname that can be resolved via DNS
* @param out IPv4 address
* @return if this function was successfull and out contains a valid IP address
*/
bool stringToIPAddress(const char* str, in_addr* out);
};