Added error checking for return value from 'easysock' functions

master
Aadhavan Srinivasan 2 years ago
parent 4d606df24d
commit 22f7df1524

@ -73,6 +73,9 @@ int main(int argc,char* argv[]) {
char preferred_transport = 'T';
struct sockaddr addr_struct;
int server_sock = create_local(preferred_local_network,preferred_transport,local_addr,local_port,&addr_struct);
if (server_sock < 0) {
exit(-1 * server_sock);
}
int addrlen;
if (check_ip_ver(local_addr) == 4) {
addrlen = sizeof(struct sockaddr_in);
@ -90,6 +93,9 @@ int main(int argc,char* argv[]) {
while (1) {
int from_client = accept(server_sock,&addr_struct,(socklen_t *)&addrlen);
int to_server = create_remote(preferred_remote_network,preferred_transport,remote_addr,remote_port,&remote_addr_struct);
if (to_server < 0) {
exit(-1 * to_server);
}
printf("Connection established to %s:%d\n",remote_addr,remote_port);
if (fork() == 0) {

Loading…
Cancel
Save