CPP=g++ -std=c++14
all:server client
echo "ok"
server: server.cpp config.h socket.o
${CPP} server.cpp socket.o -o server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// As seen on http://www.di.uniba.it/~reti/LabProRete/Interazione(TCP)Client-Server_Portabile.pdf | |
#if defined WIN32 | |
#include <winsock.h> | |
#else | |
#define closesocket close | |
#include <sys/socket.h> | |
#include <arpa/inet.h> | |
#include <unistd.h> | |
#endif | |
#include <stdio.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CustomFunction: | |
def __init__(self, func): | |
self.func = func | |
def __call__(self, *args, **kwargs): | |
return self.func(*args, **kwargs) | |
def __str__(self): | |
return "A custom function" | |