title: How to declare ip address to use it with multiple functions?
body: <p>I'm implementing a simple client-server program. Some parts of the i wrote is:</p>
  
  <pre><code>  int main(void){  
      using namespace boost::asio;
      using namespace std;
       const std::string ip = "localhost";
       const int port       = 10500;
       ip::address addr = ip::address::from_string(ip);
       ip::tcp::endpoint ep(addr, port);
      ip::tcp::iostream s(ep);
  
       s &lt;&lt; "TERMINATE\n" &lt;&lt; std::flush;} //This sends Terminate command to the server.
     }
    void function(void){
         s &lt;&lt; "TERMINATE\n" &lt;&lt; std::flush;} // This part doesn't work.
  
        }
  </code></pre>
  
  <p>I'm new to the boost asio and network programming. And working on windows MingGW.</p>
  
  <p>As in the code above i declared the ip address in the main function, but when i try  to use it in other functions declared outside of main it doesnt work. Comes with an error like:
  's' was not declared in this scope.
  If it was a normal variable I'd declare it outside of the main and  all of the other functions  can share. But that would not work for this. Where and how  do you  need to declare the ip address and port. I'm assuming </p>
  
  <pre><code>using namespace boost::asio;
  using namespace std;
  const std::string ip = "localhost";
  const int port = 10500;
  ip::address addr = ip::address::from_string(ip);
  ip::tcp::endpoint ep(addr, port);
  ip::tcp::iostream s(ep);
  </code></pre>
  
  <p>above part is doing the declaration.</p>