Right here:

Code:
	if(strcmp(ip,NULL)==0){
	
		ad->sin_addr.s_addr = INADDR_ANY;

	}
You can't strcmp(NULL,NULL). What you should do here is just:
Code:
if (!ip) ad->sin_addr.s_addr = INADDR_ANY;
! is negation, so that is short for "if (ip == NULL)" (since NULL is false, !ip will be true if ip is false/NULL).