Ik probeer een simpele client/server applicatie te maken in C++. De server lijkt te draaien en nu probeer ik de client een connectie te laten maken, dmv. Socket::connect.
Errno geeft een foutmelding EACCES, EPERM, wat betekent "The user tried to connect to a broadcast address without having the socket broadcast a flag enabled or the connection request failed becuase of a local firewall rule."
Ik heb de firewalls uitgezet, dus daar ligt het niet aan.
Dit is de code:
Waar kan dit aan liggen?
Errno geeft een foutmelding EACCES, EPERM, wat betekent "The user tried to connect to a broadcast address without having the socket broadcast a flag enabled or the connection request failed becuase of a local firewall rule."
Ik heb de firewalls uitgezet, dus daar ligt het niet aan.
Dit is de code:
C++:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
| bool Socket::connect(const std::string host, const int port) { if(!isValid()) return false; adress.sin_family = AF_INET; adress.sin_port = htons(port); int status = inet_pton(AF_INET, host.c_str(), &adress.sin_addr); if(errno == EAFNOSUPPORT) return false; status = ::connect(mSocket, (sockaddr*) &adress, sizeof(adress)); if(errno == EACCES, EPERM) { std::cout << "error!\n"; } if(status == 0) { std::cout << "Connected to the server..."; return true; } return false; } |
Waar kan dit aan liggen?
[ Voor 4% gewijzigd door Explore op 10-07-2005 18:21 ]
[ specs ] [ Tweaker gallery ]