Hi, i have the code below, i want to separate the open socket code from the writting fucntions, i want to call a escribir() function from the main but iˇm not clear the value i have to pass the function, inthe way i have below it has not work.
thanks
#include <ctime>
#include <iostream>
#include <string>
#include <boost/asio.hpp>

using boost::asio::ip::tcp;

void escribir( tcp::socket socket){

  std::string message = "mensaje";

      boost::system::error_code ignored_error;
      boost::asio::write(socket, boost::asio::buffer(message),
          boost::asio::transfer_all(), ignored_error);

}

int main()
{ int contador=0;

  try
  {
    boost::asio::io_service io_service;

    tcp::acceptor acceptor(io_service, tcp::endpoint(tcp::v4(), 5544));
 for (;;)
    {
      tcp::socket socket(io_service);
      acceptor.accept(socket);
      escribir(socket);
    }

  }
  catch (std::exception& e)
  {
    std::cerr << e.what() << std::endl;
  }

  return 0;
}

--
Ing Pedro Alonso Chaparro Valero
Ciudad Politecnica de la Innovación
iTEAM - Mobile Communications Group
Polytechnic University of Valencia
C\ Camino de Vera S/N, Edificio 8G
46022 Valencia, Spain