과제 제출본..

This commit is contained in:
2025-05-04 23:43:04 +09:00
parent 8ffe3a7519
commit 993d41736d
6 changed files with 185 additions and 291 deletions

View File

@@ -150,6 +150,7 @@ public:
RequestType requestType;
DataType dataType;
std::uint16_t packetLength;
std::uint16_t sourceId[4];
std::uint16_t destId[4];
std::uint8_t data[];
} __data;
@@ -157,14 +158,18 @@ public:
};
std::uint8_t* convToN() {
__data.packetLength = ::htons(__data.packetLength);
for (int i = 0; i < 4; i++)
for (int i = 0; i < 4; i++) {
__data.sourceId[i] = ::htons(__data.sourceId[i]);
__data.destId[i] = ::htons(__data.destId[i]);
}
return serialized;
}
std::uint8_t* convToH() {
__data.packetLength = ::ntohs(__data.packetLength);
for (int i = 0; i < 4; i++)
for (int i = 0; i < 4; i++) {
__data.sourceId[i] = ::ntohs(__data.sourceId[i]);
__data.destId[i] = ::ntohs(__data.destId[i]);
}
return serialized;
}
};
@@ -197,7 +202,7 @@ public:
};
enum class ResponseStatusCode : std::uint16_t {
OK = 200,
RES_OK = 200,
CREATED = 201,
ACCEPTED = 202,
BAD_REQUEST = 400,

View File

@@ -27,7 +27,7 @@ namespace Chattr {
class IOCP;
enum class IOCPEVENT {
ERR,
ERROR_,
READ,
WRITE
};