Added int_to_inet function
This commit is contained in:
10
easysock.c
10
easysock.c
@@ -114,3 +114,13 @@ int check_ip_ver(char* address) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int int_to_inet(int network) {
|
||||||
|
if (network == 4) {
|
||||||
|
return AF_INET;
|
||||||
|
} else if (network == 6) {
|
||||||
|
return AF_INET6;
|
||||||
|
} else {
|
||||||
|
exit(207);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -51,8 +51,13 @@ It prints the error returned by 'connect' if something went wrong, and exits wit
|
|||||||
int create_remote (int network,char transport,char* address,int port,struct sockaddr* remote_addr_struct);
|
int create_remote (int network,char transport,char* address,int port,struct sockaddr* remote_addr_struct);
|
||||||
|
|
||||||
/* check_ip_ver - This function checks if the given string is an IPv4 address (returns 4),
|
/* check_ip_ver - This function checks if the given string is an IPv4 address (returns 4),
|
||||||
IPv6 address (returns 6) or neither (returns -1).
|
IPv6 address (returns 6) or neither (returns -1). */
|
||||||
|
|
||||||
int check_ip_ver(char* address);
|
int check_ip_ver(char* address);
|
||||||
|
|
||||||
|
/* int_to_inet - Takes an int value (4 for IPv4, 6 for IPv6) and returns AF_INET or
|
||||||
|
AF_INET6 respectively. */
|
||||||
|
|
||||||
|
int int_to_inet(int network);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user