I am working on a project involving sockets and QT. I want to use the socket functions from within sys/socket.h and not the ones that come with QT. (this is because I am following some tutorial type stuff).
The following code:
if (connect(sock, (const struct sockaddr *) &servAddr, (socklen_t) sizeof(servAddr)) < 0){ //connect to server
caused the following error:
error: no matching function for call to 'MainWindow::connect(int&, const sockaddr*, socklen_t)'
I fixed this by adding :: in front of connect() like so:
if (::connect(sock, (const struct sockaddr *) &servAddr, (socklen_t) sizeof(servAddr)) < 0){ //connect to server
As I understand it I can use :: prefixed with a namespace but what does it mean in the current use? I only found out how to fix my error from a forum post but it did not explain the underlying thought behind it. Any other tricks for using :: .