|
|
@ -52,7 +52,7 @@ void create_addr(int network, char* address, int port,struct sockaddr* dest) {
|
|
|
|
int create_local (int network, char transport, char* address, int port,struct sockaddr* addr_struct) {
|
|
|
|
int create_local (int network, char transport, char* address, int port,struct sockaddr* addr_struct) {
|
|
|
|
int socket = create_socket(network,transport);
|
|
|
|
int socket = create_socket(network,transport);
|
|
|
|
if (socket < 0) {
|
|
|
|
if (socket < 0) {
|
|
|
|
printf("Something went wrong creating the socket: %s\n",strerror(errno));
|
|
|
|
exit(socket);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
create_addr(network,address,port,addr_struct);
|
|
|
|
create_addr(network,address,port,addr_struct);
|
|
|
|
int addrlen;
|
|
|
|
int addrlen;
|
|
|
@ -70,8 +70,7 @@ int create_local (int network, char transport, char* address, int port,struct so
|
|
|
|
|
|
|
|
|
|
|
|
int i = bind (socket,addr_struct,(socklen_t)addrlen);
|
|
|
|
int i = bind (socket,addr_struct,(socklen_t)addrlen);
|
|
|
|
if (i < 0) {
|
|
|
|
if (i < 0) {
|
|
|
|
printf("Something went wrong: %s\n",strerror(errno));
|
|
|
|
exit(errno);
|
|
|
|
exit(-3);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return socket;
|
|
|
|
return socket;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -100,8 +99,7 @@ int create_remote (int network,char transport,char* address,int port) {
|
|
|
|
|
|
|
|
|
|
|
|
int i = connect(socket,&remote_addr_struct,(socklen_t)addrlen);
|
|
|
|
int i = connect(socket,&remote_addr_struct,(socklen_t)addrlen);
|
|
|
|
if (i < 0) {
|
|
|
|
if (i < 0) {
|
|
|
|
printf("Something went wrong: %s\n",strerror(errno));
|
|
|
|
exit(errno);
|
|
|
|
exit(-3);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return socket;
|
|
|
|
return socket;
|
|
|
|
}
|
|
|
|
}
|
|
|
|