Network wrapper protocol as part of the practical master thesis
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

29 lines
634 B

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