#include #include "connection.h" connection_t* connection_create(conntype_e type){ connection_t* conn = malloc(sizeof(connection_t)); if(NULL == conn) { printf("connection_create: malloc failed\n"); } else { conn->type = type; conn->fd = -1; } return conn; } int connection_destroy(connection_t* conn) { int err = 0; if(NULL != conn) { if(-1 != conn->fd) { err = close(conn->fd); if(-1 == err) { printf("connection_destroy: close connection failed"); } } free(conn); } return err; }