I am doing some socket programming and have created a library.
int CreateSocket(char* domain, char* type, int protocal, unsigned int portNumber, char* IPAddress)
struct sockaddr_in serverAddress;
int sockfd = 0;
int connectionResult = 0;
printf("family = %s", family);
printf("Char* domain = %s\n", domain);
printf("(int) domain = %d\n", (int) domain);
printf("(int) *domain = %d\n", (int) *domain);
serverAddress.sin_family = *domain; //PROBLEM HERE ASSIGNING THE FAMILY DOMAIN.
serverAddress.sin_port = htons(portNumber);
serverAddress.sin_addr.s_addr = inet_addr(IPAddress);
memset(serverAddress.sin_zero, '\0', sizeof(serverAddress.sin_zero));
sockfd = socket(PF_INET, SOCK_STREAM, 0);
printf("socket(PF_INET, SOCK_STREAM) = %d", sockfd);
if(sockfd == -1)
I have above function that will pass the address family (AF_INET) with some other parameters. The parameter name is domain.
I think the problem is that the AF_INET is a key word so cannot assign a string representative. As you can see from my print outs I have tried many things.
I need this parameter passed in as the user will either enter the address family or protocol family that they want to use. This will also be the same for the SOCK_STREAM or SOCK_DGRAM.
Many thanks for any advice,