|
|
|
@ -75,15 +75,14 @@ int create_local (int network, char transport, char* address, int port,struct so
|
|
|
|
|
return socket;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int create_remote (int network,char transport,char* address,int port) {
|
|
|
|
|
int create_remote (int network,char transport,char* address,int port,struct sockaddr* remote_addr_struct) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int socket = create_socket(network,transport);
|
|
|
|
|
if (socket == -1) {
|
|
|
|
|
exit(-1);
|
|
|
|
|
if (socket < 0) {
|
|
|
|
|
exit(socket);
|
|
|
|
|
}
|
|
|
|
|
struct sockaddr remote_addr_struct;
|
|
|
|
|
create_addr(network,address,port,&remote_addr_struct);
|
|
|
|
|
create_addr(network,address,port,remote_addr_struct);
|
|
|
|
|
int addrlen;
|
|
|
|
|
if (network == 4) {
|
|
|
|
|
addrlen = sizeof(struct sockaddr_in);
|
|
|
|
@ -97,7 +96,7 @@ int create_remote (int network,char transport,char* address,int port) {
|
|
|
|
|
This should be set to the size of 'sockaddr_in' for IPv4, and 'sockaddr_in6' for IPv6.
|
|
|
|
|
See https://stackoverflow.com/questions/73707162/socket-bind-failed-with-invalid-argument-error-for-program-running-on-macos */
|
|
|
|
|
|
|
|
|
|
int i = connect(socket,&remote_addr_struct,(socklen_t)addrlen);
|
|
|
|
|
int i = connect(socket,remote_addr_struct,(socklen_t)addrlen);
|
|
|
|
|
if (i < 0) {
|
|
|
|
|
exit(errno);
|
|
|
|
|
}
|
|
|
|
|