I'm playing with the unix sockets. The code compiles fine but I get the following message on execute
Invalid argument Here is the code i use. It's pretty simple I think
#include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <stdio.h> #include <stdlib.h> #define PORT 7000 int main(){ int socket_desc; struct sockaddr_in address; socket_desc = socket(AF_INET, SOCK_STREAM, 0); if(socket_desc == -1) perror("Create socket"); /* type of socket created in socket() */ address.sin_family = AF_INET; address.sin_addr.s_addr = INADDR_ANY; /* set port */ address.sin_port = htons(PORT); while(1) { /* bind the socket to the port specified above */ if(bind(socket_desc,(struct sockaddr *)&address, sizeof(address)) < 0) { perror("Error"); exit(-1); } } return 0; }
main()?