dimanche 5 avril 2015

What is wrong with this sys/socket.h bind() function call?

I am trying to create a multi-threaded TCP server using C++11 threads + POSIX sockets. However, I am getting this weird error, when calling bind() function :



g++ -Wall -pedantic -std=c++11 -g -o server main.cpp -lpthread
main.cpp: In function ‘int main(int, const char**)’:
main.cpp:49:58: error: invalid conversion from ‘int (*)(int, int, int) throw ()’ to ‘int’ [-fpermissive]
bind(socket, (struct sockaddr *) &server, sizeof(server));
^


What is wrong with this function call ? What does this error mean ? What am I doing wrong ? I already did "my homework", but I didn't find anything useful.


I am including these headers :



#include <sys/types.h>
#include <sys/socket.h>
#include <cstdlib>
#include <cstdio>
#include <unistd.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <strings.h>
#include <string.h>
#include <iostream>
#include <thread>
#include <vector>


Running Ubuntu x86_64 with gcc (Ubuntu 4.9.1-16ubuntu6) 4.9.1


Aucun commentaire:

Enregistrer un commentaire