I read the news today, oh boy.
This commit is contained in:
		| @@ -28,7 +28,7 @@ namespace netprot { | ||||
|  | ||||
| 	struct Packet { // Pour pouvoir recevoir les paquets du recv() sans avoir à les aiguiller dans la même thread. | ||||
| 		void* ptr = nullptr; // Notez que le pointeur doit être supprimé séparément lorsqu'il n'est plus utile. | ||||
| 		PACKET_TYPE type; | ||||
| 		PACKET_TYPE type = PACKET_TYPE::ERR; | ||||
| 	}; | ||||
|  | ||||
| 	struct Keys { | ||||
| @@ -145,10 +145,14 @@ namespace netprot { | ||||
|  | ||||
| 	template <class T> void sendPack(SOCKET sock, T* pack, Buffer* buf); | ||||
| 	template <class T> void sendPackTo(SOCKET sock, T* pack, Buffer* buf, sockaddr_in* sockad); | ||||
| 	 | ||||
| 	std::vector<Packet> recvPacks(SOCKET sock, Buffer* buf); | ||||
|  | ||||
| 	template <class T> | ||||
| 	void sendPack(SOCKET sock, T* pack, char** buf, uint32_t* buflen) { | ||||
| 		netprot::Serialize(pack, buf, buflen); | ||||
| 		memset(buf->ptr[buf->len], , '\0', sizeof(uint64_t) + sizeof(uint8_t)); | ||||
| 		buf->len += sizeof(uint64_t) + sizeof(uint8_t) | ||||
| 		send(sock, *buf, *buflen, 0); | ||||
| 		*buflen = BUFFER_LENGTH; | ||||
| 	} | ||||
| @@ -157,6 +161,8 @@ namespace netprot { | ||||
| 	void sendPackTo(SOCKET sock, T* pack, char** buf, uint32_t* buflen, sockaddr_in* sockad) { | ||||
| 		sockaddr_in addr = *sockad; | ||||
| 		netprot::Serialize(pack, buf, buflen); | ||||
| 		memset(buf->ptr[buf->len], , '\0', sizeof(uint64_t) + sizeof(uint8_t)); | ||||
| 		buf->len += sizeof(uint64_t) + sizeof(uint8_t) | ||||
| 		sendto(sock, *buf, *buflen, 0, (sockaddr*)&addr, sizeof(addr)); | ||||
| 		*buflen = BUFFER_LENGTH; | ||||
| 	} | ||||
| @@ -164,6 +170,8 @@ namespace netprot { | ||||
| 	template <class T> | ||||
| 	void sendPack(SOCKET sock, T* pack, Buffer* buf) { | ||||
| 		netprot::Serialize(pack, &buf->ptr, &buf->len); | ||||
| 		memset(buf->ptr[buf->len], , '\0', sizeof(uint64_t) + sizeof(uint8_t)); | ||||
| 		buf->len += sizeof(uint64_t) + sizeof(uint8_t) | ||||
| 		send(sock, buf->ptr, buf->len, 0); | ||||
| 		buf->rstLen(); | ||||
| 	} | ||||
| @@ -172,8 +180,12 @@ namespace netprot { | ||||
| 	void sendPackTo(SOCKET sock, T* pack, Buffer* buf, sockaddr_in* sockad) { | ||||
| 		sockaddr_in addr = *sockad; | ||||
| 		netprot::Serialize(pack, &buf->ptr, &buf->len); | ||||
| 		memset(buf->ptr[buf->len], ,'\0', sizeof(uint64_t) + sizeof(uint8_t)); | ||||
| 		buf->len += sizeof(uint64_t) + sizeof(uint8_t) | ||||
| 		sendto(sock, buf->ptr, buf->len, 0, (sockaddr*)&addr, sizeof(addr)); | ||||
| 		buf->rstLen(); | ||||
| 	} | ||||
|  | ||||
|  | ||||
| }; | ||||
| #endif | ||||
|   | ||||
		Reference in New Issue
	
	Block a user