I am trying to compile this code and I am getting an error I don't understand
Here is the section of code:
And this is the error it says I have.Code:int main(int argc, char *argv[]) { int sock; struct sockaddr_in addr, claddr; pid_t pid; int i, found; int flag; int rc; pthread_t threadid; signal(SIGCHLD, SIG_IGN); if (argc >= 2) { strcpy(rootdir, argv[1]); } else { getcwd(rootdir, 512); } sock = socket(PF_INET, SOCK_STREAM, 0); if (sock < 0) { printf("Error in socket.\n"); return -1; } flag = 1; if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &flag, sizeof(flag)) < 0) { printf("Error in setsockopt for REUSEADDR\n"); return -1; } addr.sin_family = AF_INET; addr.sin_port = htons(7513); addr.sin_addr.s_addr = INADDR_ANY; if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) { printf("Error in bind\n"); return -1; } if (listen(sock, 1) < 0) { printf("Error in listen\n"); return -1; } while (1) { int consock, size; size = sizeof(claddr); consock = accept(sock, (struct sockaddr *)&claddr, &size); //printf("New connection arriving...\n"); if (consock < 0) { printf("Error in accept\n"); return 0; }
I am new to programing in C and have never done socket programing before.Code:/home/roger/Nethost/main.cpp|898|error: invalid conversion from ‘int*’ to ‘socklen_t*’| /home/roger/Nethost/main.cpp|898|error: initializing argument 3 of ‘int accept(int, sockaddr*, socklen_t*)’|
Any help would be appreciated



LinkBack URL
About LinkBacks



