Thread: My Client Socket Program not receiving response

  1. #1
    Registered User
    Join Date
    Sep 2022
    Posts
    11

    My Client Socket Program not receiving response

    I created a simple http client socket program that fetches data via a GET Request. Sadly, it does not seem to be returning a http response (it seems to freeze). The request appears t be valid and the http protocol version is 1.1. Here is the code in C++


    Code:
    #include <fstream>
    
    #include <iostream>
    #include <sys/socket.h>
    #include <sys/types.h>
    #include <netdb.h>
    #include <netinet/in.h>
    #include <arpa/inet.h>
    #include <unistd.h>
    #include <string>
    #include <cstring>
    
    using namespace std;
    
    string resolveToIPAddress(string, string);
    int getPortNum(string);
    string getUrlPath(string);
    string getDomain(string);
    string getDomainWithFile(string);
    string getUrlWithNoPort(string);
    string getFileFromURL(string);
    bool hasHTTPProtocol(string);
    bool hasPortNum(string);
    bool checkIfValidIPAddress(string);
    
    int main(int argc, char **argv)
    {
      //Create a file to be opened for output
      ofstream out_file;
      out_file.open("output.txt", ios::out);
      int connection_port = 0, send_req, recv_req;
      string ip_addr = "", domain = "", ipFromDomain = "", file_to_get = "";
      ip_addr = argv[1];            //point ip address argument to the 2nd indice in the arguments
    
    
      //if there is a port number, Get port number (extract it from URL)
      if (hasPortNum(ip_addr)) {
        connection_port = getPortNum(ip_addr);
        domain = getDomain(ip_addr);
      }
      //if there is no port number, set default port number = 80 and set domain to truncated ip address
      else {
        connection_port = 80;
        domain = getDomain(ip_addr);
      }
    
      file_to_get = getFileFromURL(ip_addr);
      cout << "Domain: " << domain << endl;
      cout << "Port Number: " << connection_port << endl;
      cout << "File requested: " << file_to_get << endl;
      //resolve domain to ipAddress
      ipFromDomain = resolveToIPAddress(domain, to_string(connection_port));
      //Connect to iP Address with port and return metadata
    
      //Create the socket
      int http_client_socket = socket(AF_INET, SOCK_STREAM, 0);
    
      // connect address and contain socket
      struct sockaddr_in connection_addr;
      connection_addr.sin_family = AF_INET; //set the addressfamily type to INET 
      connection_addr.sin_port = htons(connection_port);  //set socket to parsed port number
      cout << "ip address: " << ipFromDomain << endl; //checking to see if ip address is well converted
      inet_aton(ipFromDomain.c_str(), &connection_addr.sin_addr); //convert ip address from IPV4 notation string and store it into structure
    
      //Connect to server address
      if (connect
          (http_client_socket, (struct sockaddr *) &connection_addr,
           sizeof(connection_addr)) != 0) {
        cout << "Connection with the server failed..." << endl;
        exit(0);
      }
      //Logic for HTTP GET Request
      string http_request = "GET /" + file_to_get + " HTTP/1.1\r\n\r\n";
      cout << http_request << endl;
      //string http_response;
      string http_response;
    
      send(http_client_socket, http_request.c_str(), sizeof(http_request), 0);
      recv(http_client_socket, &http_response, 999999999, 0);
    
      out_file << http_response << endl;
    
      //close the file
      out_file.close();
    
      //close the socket
      close(http_client_socket);
      return 0;
    }
    
    string getUrlWithNoPort(string url)
    {
      if (hasHTTPProtocol(url))
        return url.substr(7, url.length() - 7);
      return url;
    }
    
    //Get URL without port and path
    string getDomain(string url)
    {
      string urlWithoutPortandPath = "";
      int i = 0;
      //Check if full URL has a protocol
      if (hasHTTPProtocol(url)) {
        //if it has a protocol truncate the protocol from FQDN
        i = 7;
        while (url != '/') {
    
    
          //for (int i = 7; i < url.length(); i++) {
          if (url == ':') {
            break;
          }
          urlWithoutPortandPath += url;
          i++;
          //}
        }
        return urlWithoutPortandPath;
      }
      //if it does not have a protocol remove port number and path
      while (url != '/') {
        //for (int i = 0; i < url.length(); i++) {
        if (url == ':') {
          break;
        }
        urlWithoutPortandPath += url;
        i++;
      }
      return urlWithoutPortandPath;
    }
    
    string getDomainWithFile(string url)
    {
      string urlWithoutPortandPath = "";
      //Check if full URL has a protocol
      if (hasHTTPProtocol(url)) {
        //if it has a protocol truncate the protocol from FQDN
        for (int i = 7; i < url.length(); i++) {
          if (url == ':') {
            break;
          }
          urlWithoutPortandPath += url;
        }
        return urlWithoutPortandPath;
      }
      //if it does not have a protocol remove port number and path
    
      for (int i = 0; i < url.length(); i++) {
        if (url == ':') {
          break;
        }
        urlWithoutPortandPath += url;
      }
      return urlWithoutPortandPath;
    }
    
    bool hasHTTPProtocol(string url)
    {
      string httpProtocol = url.substr(0, 7);
      if (httpProtocol == "http://")
        return true;
      return false;
    }
    
    int getPortNum(string url)
    {
      string port = "";
      int portNum, portIdx = 0, pathIdx = 0, portEndIdx = 0;
      if (hasHTTPProtocol(url)) {
        for (int i = 7; i < url.length(); i++) {
          if (url == ':')
            portIdx = i + 1;
        }
      }
    
    
      string fromPortToPath = url.substr(portIdx, url.length() - portIdx);
      cout << "Port to Path: " << fromPortToPath << endl;
    
      for (int i = 0; i < fromPortToPath.length(); i++) {
        if (fromPortToPath == '/') {
          pathIdx = i + 1;
          portEndIdx = i;
          break;
        }
      }
      port = fromPortToPath.substr(0, portEndIdx);
      portNum = stoi(port);
      return portNum;
    }
    
    string getUrlPath(string url)
    {
      string urlPath = "";
      int pathIdx = 0, portIdx = 0, portEndIdx = 0;
      if (hasHTTPProtocol(url)) {
        for (int i = 7; i < url.length(); i++) {
          if (url == ':')
            portIdx = i + 1;
        }
      }
    
      string fromPortToPath = url.substr(portIdx, url.length() - portIdx);
      cout << "Port to Path: " << fromPortToPath << endl;
    
      for (int i = 0; i < fromPortToPath.length(); i++) {
        if (fromPortToPath == '/') {
          pathIdx = i + 1;
          portEndIdx = i;
          break;
        }
      }
      urlPath =
          fromPortToPath.substr(portEndIdx + 1, fromPortToPath.length() - pathIdx);
      return urlPath;
    }
    
    bool hasPortNum(string url)
    {
      if (hasHTTPProtocol(url)) {
        for (int i = 7; i < url.length(); i++) {
          if (url == ':')
            return true;
        }
      } else {
        for (int i = 0; i < url.length(); i++) {
          if (url == ':')
            return true;
        }
      }
    
      return false;
    }
    
    //Resolves a string hostname e.g. google.com into an ipaddress (practically a DNS function)
    string resolveToIPAddress(string urlString, string portNum)
    {
      struct addrinfo hints, *results;
      struct addrinfo *result;
      int error, sock_id;
      string numericalIPS[100];
      //set all bits in hints to zero
      memset(&hints, 0, sizeof(hints));
      hints.ai_family = AF_INET;
      hints.ai_socktype = SOCK_STREAM;
    
      if ((error =
           getaddrinfo(urlString.c_str(), portNum.c_str(), &hints,
                       &results)) != 0) {
        cout << "error " << error << ":" << gai_strerror(error) << endl;
      }
    
      int i = 0;
      //loop through results
      for (result = results; result != nullptr; result = result->ai_next) {
        struct sockaddr_in *ip_addr;
        ip_addr = (struct sockaddr_in *) result->ai_addr;
        numericalIPS = inet_ntoa(ip_addr->sin_addr);
        i++;
      }
      return numericalIPS[0];
    }
    
    string getFileFromURL(string url)
    {
      int idxToFile;
      string file_request;
      string path_to_file = getDomainWithFile(url);
      for (int i = 0; i < path_to_file.length(); i++) {
        if (path_to_file == '/') {
          idxToFile = i + 1;
        }
      }
      file_request =
          path_to_file.substr(idxToFile, path_to_file.length() - idxToFile);
      return file_request;
    }
    I took the following measures to debug the application:

    1. Stepping through the code
    2. adding print statements to make sure that the domain, port number, the ip address the domain resolves to via DNS, and the file that is requested are correct...They appear to be.


    The way I dissected the data one by one is by getting the domain, port number, path to the file. I went ahead and used DNS to resolve the hostname to an IPv4 address. I am still running into problems. Thanks!
    Last edited by Salem; 09-26-2022 at 03:28 AM. Reason: removed crayola

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    1. When posting code, please use "copy as text" in your IDE and/or "paste as text" in your browser.
    Your fancy colour scheme is a mess when posted on forums. I've fixed it for you this time.

    2.
    Code:
      send(http_client_socket, http_request.c_str(), sizeof(http_request), 0);
      recv(http_client_socket, &http_response, 999999999, 0);
    Lying about both your string sizes isn't going to work.
    - sizeof() is not the same as string.size()
    - Your response isn't even pointing to the data part of the string, not that you've even reserved millions of bytes for it.

    Use a char buffer in the first instance for receiving, just to make sure it works.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Sep 2022
    Posts
    11
    Quote Originally Posted by Salem View Post
    1. When posting code, please use "copy as text" in your IDE and/or "paste as text" in your browser.
    Your fancy colour scheme is a mess when posted on forums. I've fixed it for you this time.

    2.
    Code:
      send(http_client_socket, http_request.c_str(), sizeof(http_request), 0);
      recv(http_client_socket, &http_response, 999999999, 0);
    Lying about both your string sizes isn't going to work.
    - sizeof() is not the same as string.size()
    - Your response isn't even pointing to the data part of the string, not that you've even reserved millions of bytes for it.

    Use a char buffer in the first instance for receiving, just to make sure it works.
    Thanks Salem for your input. I greatly appreciate it! I am new to socket programming, so please pardon my ignorance, I specified a buffer of 999mb in the recv buffer because I wanted to have the ability to receive that much memory. In regards to string.size() am I correct to assume that you mean string.length()? Thanks!

  4. #4
    Registered User
    Join Date
    Sep 2022
    Posts
    11
    Hello Salem I made the suggested changes:

    Code:
       //Logic for HTTP GET Request
    
        string http_request = "GET /" + file_to_get + " HTTP/1.1\r\n\r\n";
    
        cout << http_request << endl;
    
        //string http_response;
        char http_response[4096];
    
    
        send(http_client_socket, http_request.c_str(), http_request.size(), 0);
        recv(http_client_socket, &http_response, sizeof(http_response), 0);
    I am however getting a 400 response code (Bad Request). Is there something wrong in the way I am making the request? Thanks!
    Last edited by badCProgrammeur; 09-26-2022 at 09:48 AM.

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    > In regards to string.size() am I correct to assume that you mean string.length()?
    Yes.

    > I specified a buffer of 999mb in the recv buffer because I wanted to have the ability to receive that much memory.
    But your buffer is only going to fill up at the rate of the MTU size.
    Maximum transmission unit - Wikipedia

    Certainly, recv() will not wait around to fill 1GB of buffer.

    Your inner loop around recv should be something like this.
    Code:
    char buff[BUFSIZ];
    int bp = 0;
    int size = BUFSIZ;
    while ( (n=recv(http_client_socket, &buff[bp], size, 0)) > 0 ) {
      bp += n;
      size -= n;
    }
    if ( n == 0 ) // connection closed
    if ( n < 0 ) // there's a problem.
    When buff is full you append to your string with say
    Code:
    http_response += string(buff,bp);
    Wireshark is your friend.
    Wireshark * Go Deep.
    Use it to spy on the wire, to see what gets sent and what comes back.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  6. #6
    Registered User
    Join Date
    Sep 2022
    Posts
    11
    Quote Originally Posted by Salem View Post
    > In regards to string.size() am I correct to assume that you mean string.length()?
    Yes.

    > I specified a buffer of 999mb in the recv buffer because I wanted to have the ability to receive that much memory.
    But your buffer is only going to fill up at the rate of the MTU size.
    Maximum transmission unit - Wikipedia

    Certainly, recv() will not wait around to fill 1GB of buffer.

    Your inner loop around recv should be something like this.
    Code:
    char buff[BUFSIZ];
    int bp = 0;
    int size = BUFSIZ;
    while ( (n=recv(http_client_socket, &buff[bp], size, 0)) > 0 ) {
      bp += n;
      size -= n;
    }
    if ( n == 0 ) // connection closed
    if ( n < 0 ) // there's a problem.
    When buff is full you append to your string with say
    Code:
    http_response += string(buff,bp);
    Wireshark is your friend.
    Wireshark * Go Deep.
    Use it to spy on the wire, to see what gets sent and what comes back.
    Thanks for your input Salem. I did a wireshark trace with some of the modifications you suggested. I noticed in the three-way tcp handshake that there are ECN and CWR bits set. I assume that these are somehow related to bandwidth congestion.

    My Client Socket Program not receiving response-screen-shot-2022-09-26-9-56-33-am-jpg

    After the ACK from my client machine to the test server, I immediately see the GET Request being made.

    My Client Socket Program not receiving response-screen-shot-2022-09-26-10-00-35-am-jpg

    Something seems a bit off in the GET Request, but I can't put my finger on it.

    Here is some of the modified code:
    Code:
    //Logic for HTTP GET Request
    
        string http_request = "GET /" + file_to_get + " HTTP/1.1\r\n\r\n";
        cout << http_request << endl;
    
        //string http_response;
    
        //char http_response[4096];
    
    
        send(http_client_socket, http_request.c_str(), http_request.length(), 0);
    
        char buff[BUFSIZ];
    
        int bp = 0;
    
        int size = BUFSIZ;
    
        int n;
    
        while ( (n=recv(http_client_socket, &buff[bp], size, 0)) > 0 ) {
    
            bp += n;
    
            size -= n;
    
            
    
        }
        if ( n == 0 ) { cout << "Connection Closed\n";}// connection closed
    
        if ( n < 0 ) { cout << "Error connection lost\n"; }// there's a problem.
    
        
    
    
        out_file << buff << endl;
        cout << buff << endl;

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Well you need to look closely at what's in packet 139, because the response in packet 141 is "bad request".
    Also, you only need worry about protocol=HTML messages. The TCP chatter probably isn't all that useful.

    > send(http_client_socket, http_request.c_str(), http_request.length(), 0);
    Like recv(), there is no guarantee that the whole message is sent in a single call.

    At least start with
    Code:
    int s = send(http_client_socket, http_request.c_str(), http_request.length(), 0);
    if ( s != http_request.length() ) { std::cerr << "Oops on send\n"; }
    Are you able to fetch testcat_al.html using your browser?
    If you are, comparing the browser's version of "GET" with your version will tell you a lot.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  8. #8
    Registered User
    Join Date
    Sep 2022
    Posts
    11
    Quote Originally Posted by Salem View Post
    Well you need to look closely at what's in packet 139, because the response in packet 141 is "bad request".
    Also, you only need worry about protocol=HTML messages. The TCP chatter probably isn't all that useful.

    > send(http_client_socket, http_request.c_str(), http_request.length(), 0);
    Like recv(), there is no guarantee that the whole message is sent in a single call.

    At least start with
    Code:
    int s = send(http_client_socket, http_request.c_str(), http_request.length(), 0);
    if ( s != http_request.length() ) { std::cerr << "Oops on send\n"; }
    Are you able to fetch testcat_al.html using your browser?
    If you are, comparing the browser's version of "GET" with your version will tell you a lot.
    The http GET request is definitely different when made from the browser. In comparison:

    My Client Socket Program not receiving response-screen-shot-2022-09-26-10-43-47-am-jpg

    I noticed that IPv4 addresses are different from my browser, the IPv4 address of the test server is being resolved to 100.21.215.181 whereas in my program, it is being resolved to 34.218.221.118 I have to assume that the website's has a cluster of IP addresses and is dynamic.

    When the same site is fetched from the browser, Wireshark does show a HOST field which doesn't happen with my client socket program. That tells me I must be doing a lot of things wrong.

  9. #9
    Registered User
    Join Date
    Sep 2022
    Posts
    11
    Quote Originally Posted by badCProgrammeur View Post
    The http GET request is definitely different when made from the browser. In comparison:

    My Client Socket Program not receiving response-screen-shot-2022-09-26-10-43-47-am-jpg

    I noticed that IPv4 addresses are different from my browser, the IPv4 address of the test server is being resolved to 100.21.215.181 whereas in my program, it is being resolved to 34.218.221.118 I have to assume that the website's has a cluster of IP addresses and is dynamic.

    When the same site is fetched from the browser, Wireshark does show a HOST field which doesn't happen with my client socket program. That tells me I must be doing a lot of things wrong.
    @Salem, I have changed the code for send, and I'm not sure why still my code for the GET request is generating a different result from the browser. One thing I did notice though besides the aforementioned was that \r\n was missing from the browser request. However, from what I know, "HTTP/1.1\r\n\r\n" is needed in the GET request.

  10. #10
    Registered User
    Join Date
    May 2012
    Location
    Arizona, USA
    Posts
    948
    An HTTP/1.1 request requires a "Host" header. This header is typically used to tell the server which web site to serve (web servers often serve up numerous web sites from the same IP).

  11. #11
    Registered User
    Join Date
    Sep 2022
    Posts
    11
    Quote Originally Posted by christop View Post
    An HTTP/1.1 request requires a "Host" header. This header is typically used to tell the server which web site to serve (web servers often serve up numerous web sites from the same IP).
    Hello @christop, thanks for chiming in. So I guess my string is missing the host header then.

  12. #12
    Registered User
    Join Date
    Sep 2022
    Posts
    11
    Quote Originally Posted by christop View Post
    An HTTP/1.1 request requires a "Host" header. This header is typically used to tell the server which web site to serve (web servers often serve up numerous web sites from the same IP).
    Thanks for that, that has helped a lot. My brain is drained after all this. I think I am making one mistake. Let's say that you are making a GET Request to a URL that has 2 levels in its full path e.g.

    /location1/location2/fileLocation.txt as opposed to
    /location1/fileLocation.txt

    How does this affect the GET request?

  13. #13
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    TBH, I'm surprised it's getting as far as it is.
    The code is riddled with compilation errors.
    Code:
    $ g++ -Wall -Wextra foo.cpp 2>&1 | grep -A5 error:
    foo.cpp:107:16: error: no match for ‘operator!=’ (operand types are ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} and ‘char’)
      107 |     while (url != '/') {
          |            ~~~ ^~ ~~~
          |            |      |
          |            |      char
          |            std::string {aka std::__cxx11::basic_string<char>}
    --
    /usr/include/c++/9/system_error:319:3: note: candidate: ‘bool std::operator!=(const std::error_code&, const std::error_code&)’
      319 |   operator!=(const error_code& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:319:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      319 |   operator!=(const error_code& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:323:3: note: candidate: ‘bool std::operator!=(const std::error_code&, const std::error_condition&)’
      323 |   operator!=(const error_code& __lhs, const error_condition& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:323:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      323 |   operator!=(const error_code& __lhs, const error_condition& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:327:3: note: candidate: ‘bool std::operator!=(const std::error_condition&, const std::error_code&)’
      327 |   operator!=(const error_condition& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:327:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      327 |   operator!=(const error_condition& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:331:3: note: candidate: ‘bool std::operator!=(const std::error_condition&, const std::error_condition&)’
      331 |   operator!=(const error_condition& __lhs,
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:331:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      331 |   operator!=(const error_condition& __lhs,
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    In file included from /usr/include/c++/9/bits/locale_facets.h:48,
                     from /usr/include/c++/9/bits/basic_ios.h:37,
                     from /usr/include/c++/9/ios:44,
    --
    foo.cpp:111:15: error: no match for ‘operator==’ (operand types are ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} and ‘char’)
      111 |       if (url == ':') {
          |           ~~~ ^~ ~~~
          |           |      |
          |           |      char
          |           std::string {aka std::__cxx11::basic_string<char>}
    --
    /usr/include/c++/9/system_error:292:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_code&)’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:292:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:297:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_condition&)’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:297:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:304:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_code&)’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:304:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:311:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_condition&)’
      311 |   operator==(const error_condition& __lhs,
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:311:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      311 |   operator==(const error_condition& __lhs,
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    In file included from /usr/include/c++/9/bits/locale_facets.h:48,
                     from /usr/include/c++/9/bits/basic_ios.h:37,
                     from /usr/include/c++/9/ios:44,
    --
    foo.cpp:121:14: error: no match for ‘operator!=’ (operand types are ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} and ‘char’)
      121 |   while (url != '/') {
          |          ~~~ ^~ ~~~
          |          |      |
          |          |      char
          |          std::string {aka std::__cxx11::basic_string<char>}
    --
    /usr/include/c++/9/system_error:319:3: note: candidate: ‘bool std::operator!=(const std::error_code&, const std::error_code&)’
      319 |   operator!=(const error_code& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:319:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      319 |   operator!=(const error_code& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:323:3: note: candidate: ‘bool std::operator!=(const std::error_code&, const std::error_condition&)’
      323 |   operator!=(const error_code& __lhs, const error_condition& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:323:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      323 |   operator!=(const error_code& __lhs, const error_condition& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:327:3: note: candidate: ‘bool std::operator!=(const std::error_condition&, const std::error_code&)’
      327 |   operator!=(const error_condition& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:327:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      327 |   operator!=(const error_condition& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:331:3: note: candidate: ‘bool std::operator!=(const std::error_condition&, const std::error_condition&)’
      331 |   operator!=(const error_condition& __lhs,
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:331:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      331 |   operator!=(const error_condition& __lhs,
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    In file included from /usr/include/c++/9/bits/locale_facets.h:48,
                     from /usr/include/c++/9/bits/basic_ios.h:37,
                     from /usr/include/c++/9/ios:44,
    --
    foo.cpp:123:13: error: no match for ‘operator==’ (operand types are ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} and ‘char’)
      123 |     if (url == ':') {
          |         ~~~ ^~ ~~~
          |         |      |
          |         |      char
          |         std::string {aka std::__cxx11::basic_string<char>}
    --
    /usr/include/c++/9/system_error:292:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_code&)’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:292:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:297:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_condition&)’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:297:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:304:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_code&)’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:304:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:311:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_condition&)’
      311 |   operator==(const error_condition& __lhs,
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:311:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      311 |   operator==(const error_condition& __lhs,
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    In file included from /usr/include/c++/9/bits/locale_facets.h:48,
                     from /usr/include/c++/9/bits/basic_ios.h:37,
                     from /usr/include/c++/9/ios:44,
    --
    foo.cpp:139:15: error: no match for ‘operator==’ (operand types are ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} and ‘char’)
      139 |       if (url == ':') {
          |           ~~~ ^~ ~~~
          |           |      |
          |           |      char
          |           std::string {aka std::__cxx11::basic_string<char>}
    --
    /usr/include/c++/9/system_error:292:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_code&)’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:292:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:297:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_condition&)’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:297:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:304:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_code&)’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:304:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:311:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_condition&)’
      311 |   operator==(const error_condition& __lhs,
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:311:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      311 |   operator==(const error_condition& __lhs,
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    In file included from /usr/include/c++/9/bits/locale_facets.h:48,
                     from /usr/include/c++/9/bits/basic_ios.h:37,
                     from /usr/include/c++/9/ios:44,
    --
    foo.cpp:149:13: error: no match for ‘operator==’ (operand types are ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} and ‘char’)
      149 |     if (url == ':') {
          |         ~~~ ^~ ~~~
          |         |      |
          |         |      char
          |         std::string {aka std::__cxx11::basic_string<char>}
    --
    /usr/include/c++/9/system_error:292:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_code&)’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:292:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:297:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_condition&)’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:297:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:304:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_code&)’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:304:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:311:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_condition&)’
      311 |   operator==(const error_condition& __lhs,
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:311:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      311 |   operator==(const error_condition& __lhs,
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    In file included from /usr/include/c++/9/bits/locale_facets.h:48,
                     from /usr/include/c++/9/bits/basic_ios.h:37,
                     from /usr/include/c++/9/ios:44,
    --
    foo.cpp:171:15: error: no match for ‘operator==’ (operand types are ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} and ‘char’)
      171 |       if (url == ':')
          |           ~~~ ^~ ~~~
          |           |      |
          |           |      char
          |           std::string {aka std::__cxx11::basic_string<char>}
    --
    /usr/include/c++/9/system_error:292:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_code&)’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:292:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:297:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_condition&)’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:297:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:304:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_code&)’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:304:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:311:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_condition&)’
      311 |   operator==(const error_condition& __lhs,
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:311:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      311 |   operator==(const error_condition& __lhs,
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    In file included from /usr/include/c++/9/bits/locale_facets.h:48,
                     from /usr/include/c++/9/bits/basic_ios.h:37,
                     from /usr/include/c++/9/ios:44,
    --
    foo.cpp:181:24: error: no match for ‘operator==’ (operand types are ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} and ‘char’)
      181 |     if (fromPortToPath == '/') {
          |         ~~~~~~~~~~~~~~ ^~ ~~~
          |         |                 |
          |         |                 char
          |         std::string {aka std::__cxx11::basic_string<char>}
    --
    /usr/include/c++/9/system_error:292:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_code&)’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:292:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:297:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_condition&)’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:297:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:304:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_code&)’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:304:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:311:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_condition&)’
      311 |   operator==(const error_condition& __lhs,
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:311:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      311 |   operator==(const error_condition& __lhs,
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    In file included from /usr/include/c++/9/bits/locale_facets.h:48,
                     from /usr/include/c++/9/bits/basic_ios.h:37,
                     from /usr/include/c++/9/ios:44,
    --
    foo.cpp:198:15: error: no match for ‘operator==’ (operand types are ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} and ‘char’)
      198 |       if (url == ':')
          |           ~~~ ^~ ~~~
          |           |      |
          |           |      char
          |           std::string {aka std::__cxx11::basic_string<char>}
    --
    /usr/include/c++/9/system_error:292:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_code&)’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:292:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:297:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_condition&)’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:297:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:304:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_code&)’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:304:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:311:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_condition&)’
      311 |   operator==(const error_condition& __lhs,
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:311:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      311 |   operator==(const error_condition& __lhs,
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    In file included from /usr/include/c++/9/bits/locale_facets.h:48,
                     from /usr/include/c++/9/bits/basic_ios.h:37,
                     from /usr/include/c++/9/ios:44,
    --
    foo.cpp:207:24: error: no match for ‘operator==’ (operand types are ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} and ‘char’)
      207 |     if (fromPortToPath == '/') {
          |         ~~~~~~~~~~~~~~ ^~ ~~~
          |         |                 |
          |         |                 char
          |         std::string {aka std::__cxx11::basic_string<char>}
    --
    /usr/include/c++/9/system_error:292:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_code&)’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:292:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:297:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_condition&)’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:297:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:304:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_code&)’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:304:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:311:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_condition&)’
      311 |   operator==(const error_condition& __lhs,
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:311:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      311 |   operator==(const error_condition& __lhs,
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    In file included from /usr/include/c++/9/bits/locale_facets.h:48,
                     from /usr/include/c++/9/bits/basic_ios.h:37,
                     from /usr/include/c++/9/ios:44,
    --
    foo.cpp:222:15: error: no match for ‘operator==’ (operand types are ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} and ‘char’)
      222 |       if (url == ':')
          |           ~~~ ^~ ~~~
          |           |      |
          |           |      char
          |           std::string {aka std::__cxx11::basic_string<char>}
    --
    /usr/include/c++/9/system_error:292:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_code&)’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:292:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:297:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_condition&)’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:297:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:304:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_code&)’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:304:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:311:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_condition&)’
      311 |   operator==(const error_condition& __lhs,
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:311:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      311 |   operator==(const error_condition& __lhs,
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    In file included from /usr/include/c++/9/bits/locale_facets.h:48,
                     from /usr/include/c++/9/bits/basic_ios.h:37,
                     from /usr/include/c++/9/ios:44,
    --
    foo.cpp:227:15: error: no match for ‘operator==’ (operand types are ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} and ‘char’)
      227 |       if (url == ':')
          |           ~~~ ^~ ~~~
          |           |      |
          |           |      char
          |           std::string {aka std::__cxx11::basic_string<char>}
    --
    /usr/include/c++/9/system_error:292:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_code&)’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:292:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:297:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_condition&)’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:297:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:304:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_code&)’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:304:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:311:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_condition&)’
      311 |   operator==(const error_condition& __lhs,
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:311:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      311 |   operator==(const error_condition& __lhs,
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    In file included from /usr/include/c++/9/bits/locale_facets.h:48,
                     from /usr/include/c++/9/bits/basic_ios.h:37,
                     from /usr/include/c++/9/ios:44,
    --
    foo.cpp:258:47: error: incompatible types in assignment of ‘char*’ to ‘std::string [100]’ {aka ‘std::__cxx11::basic_string<char> [100]’}
      258 |     numericalIPS = inet_ntoa(ip_addr->sin_addr);
          |                                               ^
    foo.cpp:240:14: warning: unused variable ‘sock_id’ [-Wunused-variable]
      240 |   int error, sock_id;
          |              ^~~~~~~
    --
    foo.cpp:270:22: error: no match for ‘operator==’ (operand types are ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} and ‘char’)
      270 |     if (path_to_file == '/') {
          |         ~~~~~~~~~~~~ ^~ ~~~
          |         |               |
          |         |               char
          |         std::string {aka std::__cxx11::basic_string<char>}
    --
    /usr/include/c++/9/system_error:292:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_code&)’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:292:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:297:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_condition&)’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:297:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:304:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_code&)’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:304:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:311:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_condition&)’
      311 |   operator==(const error_condition& __lhs,
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:311:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      311 |   operator==(const error_condition& __lhs,
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    In file included from /usr/include/c++/9/bits/locale_facets.h:48,
                     from /usr/include/c++/9/bits/basic_ios.h:37,
                     from /usr/include/c++/9/ios:44,
    Edit:
    PS - don't use @username, it only causes your post to be moderated (more work for the mods), and serves no purpose to draw attention of the people you're addressing.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  14. #14
    Registered User
    Join Date
    Sep 2022
    Posts
    11
    Quote Originally Posted by Salem View Post
    TBH, I'm surprised it's getting as far as it is.
    The code is riddled with compilation errors.
    Code:
    $ g++ -Wall -Wextra foo.cpp 2>&1 | grep -A5 error:
    foo.cpp:107:16: error: no match for ‘operator!=’ (operand types are ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} and ‘char’)
      107 |     while (url != '/') {
          |            ~~~ ^~ ~~~
          |            |      |
          |            |      char
          |            std::string {aka std::__cxx11::basic_string<char>}
    --
    /usr/include/c++/9/system_error:319:3: note: candidate: ‘bool std::operator!=(const std::error_code&, const std::error_code&)’
      319 |   operator!=(const error_code& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:319:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      319 |   operator!=(const error_code& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:323:3: note: candidate: ‘bool std::operator!=(const std::error_code&, const std::error_condition&)’
      323 |   operator!=(const error_code& __lhs, const error_condition& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:323:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      323 |   operator!=(const error_code& __lhs, const error_condition& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:327:3: note: candidate: ‘bool std::operator!=(const std::error_condition&, const std::error_code&)’
      327 |   operator!=(const error_condition& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:327:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      327 |   operator!=(const error_condition& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:331:3: note: candidate: ‘bool std::operator!=(const std::error_condition&, const std::error_condition&)’
      331 |   operator!=(const error_condition& __lhs,
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:331:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      331 |   operator!=(const error_condition& __lhs,
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    In file included from /usr/include/c++/9/bits/locale_facets.h:48,
                     from /usr/include/c++/9/bits/basic_ios.h:37,
                     from /usr/include/c++/9/ios:44,
    --
    foo.cpp:111:15: error: no match for ‘operator==’ (operand types are ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} and ‘char’)
      111 |       if (url == ':') {
          |           ~~~ ^~ ~~~
          |           |      |
          |           |      char
          |           std::string {aka std::__cxx11::basic_string<char>}
    --
    /usr/include/c++/9/system_error:292:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_code&)’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:292:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:297:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_condition&)’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:297:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:304:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_code&)’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:304:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:311:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_condition&)’
      311 |   operator==(const error_condition& __lhs,
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:311:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      311 |   operator==(const error_condition& __lhs,
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    In file included from /usr/include/c++/9/bits/locale_facets.h:48,
                     from /usr/include/c++/9/bits/basic_ios.h:37,
                     from /usr/include/c++/9/ios:44,
    --
    foo.cpp:121:14: error: no match for ‘operator!=’ (operand types are ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} and ‘char’)
      121 |   while (url != '/') {
          |          ~~~ ^~ ~~~
          |          |      |
          |          |      char
          |          std::string {aka std::__cxx11::basic_string<char>}
    --
    /usr/include/c++/9/system_error:319:3: note: candidate: ‘bool std::operator!=(const std::error_code&, const std::error_code&)’
      319 |   operator!=(const error_code& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:319:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      319 |   operator!=(const error_code& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:323:3: note: candidate: ‘bool std::operator!=(const std::error_code&, const std::error_condition&)’
      323 |   operator!=(const error_code& __lhs, const error_condition& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:323:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      323 |   operator!=(const error_code& __lhs, const error_condition& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:327:3: note: candidate: ‘bool std::operator!=(const std::error_condition&, const std::error_code&)’
      327 |   operator!=(const error_condition& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:327:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      327 |   operator!=(const error_condition& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:331:3: note: candidate: ‘bool std::operator!=(const std::error_condition&, const std::error_condition&)’
      331 |   operator!=(const error_condition& __lhs,
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:331:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      331 |   operator!=(const error_condition& __lhs,
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    In file included from /usr/include/c++/9/bits/locale_facets.h:48,
                     from /usr/include/c++/9/bits/basic_ios.h:37,
                     from /usr/include/c++/9/ios:44,
    --
    foo.cpp:123:13: error: no match for ‘operator==’ (operand types are ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} and ‘char’)
      123 |     if (url == ':') {
          |         ~~~ ^~ ~~~
          |         |      |
          |         |      char
          |         std::string {aka std::__cxx11::basic_string<char>}
    --
    /usr/include/c++/9/system_error:292:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_code&)’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:292:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:297:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_condition&)’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:297:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:304:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_code&)’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:304:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:311:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_condition&)’
      311 |   operator==(const error_condition& __lhs,
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:311:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      311 |   operator==(const error_condition& __lhs,
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    In file included from /usr/include/c++/9/bits/locale_facets.h:48,
                     from /usr/include/c++/9/bits/basic_ios.h:37,
                     from /usr/include/c++/9/ios:44,
    --
    foo.cpp:139:15: error: no match for ‘operator==’ (operand types are ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} and ‘char’)
      139 |       if (url == ':') {
          |           ~~~ ^~ ~~~
          |           |      |
          |           |      char
          |           std::string {aka std::__cxx11::basic_string<char>}
    --
    /usr/include/c++/9/system_error:292:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_code&)’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:292:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:297:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_condition&)’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:297:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:304:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_code&)’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:304:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:311:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_condition&)’
      311 |   operator==(const error_condition& __lhs,
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:311:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      311 |   operator==(const error_condition& __lhs,
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    In file included from /usr/include/c++/9/bits/locale_facets.h:48,
                     from /usr/include/c++/9/bits/basic_ios.h:37,
                     from /usr/include/c++/9/ios:44,
    --
    foo.cpp:149:13: error: no match for ‘operator==’ (operand types are ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} and ‘char’)
      149 |     if (url == ':') {
          |         ~~~ ^~ ~~~
          |         |      |
          |         |      char
          |         std::string {aka std::__cxx11::basic_string<char>}
    --
    /usr/include/c++/9/system_error:292:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_code&)’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:292:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:297:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_condition&)’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:297:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:304:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_code&)’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:304:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:311:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_condition&)’
      311 |   operator==(const error_condition& __lhs,
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:311:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      311 |   operator==(const error_condition& __lhs,
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    In file included from /usr/include/c++/9/bits/locale_facets.h:48,
                     from /usr/include/c++/9/bits/basic_ios.h:37,
                     from /usr/include/c++/9/ios:44,
    --
    foo.cpp:171:15: error: no match for ‘operator==’ (operand types are ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} and ‘char’)
      171 |       if (url == ':')
          |           ~~~ ^~ ~~~
          |           |      |
          |           |      char
          |           std::string {aka std::__cxx11::basic_string<char>}
    --
    /usr/include/c++/9/system_error:292:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_code&)’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:292:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:297:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_condition&)’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:297:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:304:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_code&)’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:304:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:311:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_condition&)’
      311 |   operator==(const error_condition& __lhs,
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:311:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      311 |   operator==(const error_condition& __lhs,
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    In file included from /usr/include/c++/9/bits/locale_facets.h:48,
                     from /usr/include/c++/9/bits/basic_ios.h:37,
                     from /usr/include/c++/9/ios:44,
    --
    foo.cpp:181:24: error: no match for ‘operator==’ (operand types are ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} and ‘char’)
      181 |     if (fromPortToPath == '/') {
          |         ~~~~~~~~~~~~~~ ^~ ~~~
          |         |                 |
          |         |                 char
          |         std::string {aka std::__cxx11::basic_string<char>}
    --
    /usr/include/c++/9/system_error:292:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_code&)’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:292:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:297:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_condition&)’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:297:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:304:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_code&)’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:304:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:311:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_condition&)’
      311 |   operator==(const error_condition& __lhs,
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:311:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      311 |   operator==(const error_condition& __lhs,
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    In file included from /usr/include/c++/9/bits/locale_facets.h:48,
                     from /usr/include/c++/9/bits/basic_ios.h:37,
                     from /usr/include/c++/9/ios:44,
    --
    foo.cpp:198:15: error: no match for ‘operator==’ (operand types are ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} and ‘char’)
      198 |       if (url == ':')
          |           ~~~ ^~ ~~~
          |           |      |
          |           |      char
          |           std::string {aka std::__cxx11::basic_string<char>}
    --
    /usr/include/c++/9/system_error:292:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_code&)’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:292:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:297:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_condition&)’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:297:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:304:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_code&)’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:304:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:311:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_condition&)’
      311 |   operator==(const error_condition& __lhs,
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:311:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      311 |   operator==(const error_condition& __lhs,
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    In file included from /usr/include/c++/9/bits/locale_facets.h:48,
                     from /usr/include/c++/9/bits/basic_ios.h:37,
                     from /usr/include/c++/9/ios:44,
    --
    foo.cpp:207:24: error: no match for ‘operator==’ (operand types are ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} and ‘char’)
      207 |     if (fromPortToPath == '/') {
          |         ~~~~~~~~~~~~~~ ^~ ~~~
          |         |                 |
          |         |                 char
          |         std::string {aka std::__cxx11::basic_string<char>}
    --
    /usr/include/c++/9/system_error:292:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_code&)’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:292:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:297:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_condition&)’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:297:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:304:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_code&)’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:304:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:311:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_condition&)’
      311 |   operator==(const error_condition& __lhs,
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:311:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      311 |   operator==(const error_condition& __lhs,
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    In file included from /usr/include/c++/9/bits/locale_facets.h:48,
                     from /usr/include/c++/9/bits/basic_ios.h:37,
                     from /usr/include/c++/9/ios:44,
    --
    foo.cpp:222:15: error: no match for ‘operator==’ (operand types are ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} and ‘char’)
      222 |       if (url == ':')
          |           ~~~ ^~ ~~~
          |           |      |
          |           |      char
          |           std::string {aka std::__cxx11::basic_string<char>}
    --
    /usr/include/c++/9/system_error:292:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_code&)’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:292:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:297:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_condition&)’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:297:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:304:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_code&)’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:304:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:311:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_condition&)’
      311 |   operator==(const error_condition& __lhs,
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:311:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      311 |   operator==(const error_condition& __lhs,
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    In file included from /usr/include/c++/9/bits/locale_facets.h:48,
                     from /usr/include/c++/9/bits/basic_ios.h:37,
                     from /usr/include/c++/9/ios:44,
    --
    foo.cpp:227:15: error: no match for ‘operator==’ (operand types are ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} and ‘char’)
      227 |       if (url == ':')
          |           ~~~ ^~ ~~~
          |           |      |
          |           |      char
          |           std::string {aka std::__cxx11::basic_string<char>}
    --
    /usr/include/c++/9/system_error:292:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_code&)’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:292:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:297:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_condition&)’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:297:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:304:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_code&)’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:304:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:311:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_condition&)’
      311 |   operator==(const error_condition& __lhs,
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:311:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      311 |   operator==(const error_condition& __lhs,
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    In file included from /usr/include/c++/9/bits/locale_facets.h:48,
                     from /usr/include/c++/9/bits/basic_ios.h:37,
                     from /usr/include/c++/9/ios:44,
    --
    foo.cpp:258:47: error: incompatible types in assignment of ‘char*’ to ‘std::string [100]’ {aka ‘std::__cxx11::basic_string<char> [100]’}
      258 |     numericalIPS = inet_ntoa(ip_addr->sin_addr);
          |                                               ^
    foo.cpp:240:14: warning: unused variable ‘sock_id’ [-Wunused-variable]
      240 |   int error, sock_id;
          |              ^~~~~~~
    --
    foo.cpp:270:22: error: no match for ‘operator==’ (operand types are ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} and ‘char’)
      270 |     if (path_to_file == '/') {
          |         ~~~~~~~~~~~~ ^~ ~~~
          |         |               |
          |         |               char
          |         std::string {aka std::__cxx11::basic_string<char>}
    --
    /usr/include/c++/9/system_error:292:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_code&)’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:292:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      292 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:297:3: note: candidate: ‘bool std::operator==(const std::error_code&, const std::error_condition&)’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:297:32: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_code&’
      297 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:304:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_code&)’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:304:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      304 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    /usr/include/c++/9/system_error:311:3: note: candidate: ‘bool std::operator==(const std::error_condition&, const std::error_condition&)’
      311 |   operator==(const error_condition& __lhs,
          |   ^~~~~~~~
    /usr/include/c++/9/system_error:311:37: note:   no known conversion for argument 1 from ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘const std::error_condition&’
      311 |   operator==(const error_condition& __lhs,
          |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    In file included from /usr/include/c++/9/bits/locale_facets.h:48,
                     from /usr/include/c++/9/bits/basic_ios.h:37,
                     from /usr/include/c++/9/ios:44,
    Edit:
    PS - don't use @username, it only causes your post to be moderated (more work for the mods), and serves no purpose to draw attention of the people you're addressing.
    Hey Salem, I have made numerous modifications and I am not getting any errors to be honest (never actually did).

    myMac:ProgrammingProjects Moussa$ !496
    g++ -g http_client.cpp -o http_client
    myMac:ProgrammingProjects Moussa$

    compiles just fine

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Client Socket Program to connect to SSH Server
    By emmaclark in forum C Programming
    Replies: 4
    Last Post: 12-27-2016, 03:09 AM
  2. C / Unix: client program with listeninig socket
    By YocR in forum Networking/Device Communication
    Replies: 4
    Last Post: 08-16-2013, 01:27 AM
  3. not receiving messages in server/client program
    By ueg1990 in forum C Programming
    Replies: 5
    Last Post: 07-08-2012, 07:57 PM
  4. writing a client program - socket programming Linux
    By rehman12390 in forum Linux Programming
    Replies: 4
    Last Post: 01-08-2012, 04:18 PM
  5. Replies: 10
    Last Post: 01-27-2010, 01:20 AM

Tags for this Thread