This commit is contained in:
Timerix22 2022-05-08 15:17:33 +03:00
parent 95f5c1b072
commit 745ae56aad
2 changed files with 44 additions and 0 deletions

1
src/Network/knSocket.c Normal file
View File

@ -0,0 +1 @@
#include "network.h"

43
src/Network/network.h Normal file
View File

@ -0,0 +1,43 @@
#pragma once
#if __cplusplus
extern "C" {
#endif
#include "../Hashtable/Hashtable.h"
#if defined(_MSC_VER) || defined(_WIN64) || defined(_WIN32)
#include "winsock.h"
#else
#include "../Hashtable/Hashtable.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netdb.h>
#endif
#define KNPAC_MAX_DATA_SIZE 65503
typedef struct knPackage{
char header[5]; // knpac
uint8 version; // protocol version
uint16 data_size; // size of data block in bytes (1-)
uint32 package_num; // number in sequence of sent packages
uint32 destination_hash; // hash32 of knDestination.name
uint64 data_hash; // hash64 of data
uint8* data; // ptr to data
} knPackage;
typedef struct knDestination{
char* name;
} knDestination;
typedef struct knSocket {
Hashtable* destinations;
int socketfd;
} knSocket;
#if __cplusplus
}
#endif