Skip to content

pipe() error and Boost.ASIO not working #2883

@edubart

Description

@edubart

I'm currently porting an application that does use Boost.ASIO for TCP sockets. Currently I know that emscripten does support TCP networking via websocks and I have to use a websocks proxy for the incoming connections in my server. I have Boost 1.55.0 and latest stable emscripten in my setup. However a simple connect does not work.

Test case:

#include <iostream>
#include <boost/asio.hpp>

void handle_connect(const boost::system::error_code& error)
{
    std::cout << "connected!" << std::endl;
}

int main(int argc, char* argv[])
{
    boost::asio::io_service io_service;
    boost::asio::ip::tcp::endpoint endpoint(boost::asio::ip::address::from_string("127.0.0.1"), 7000);
    boost::asio::ip::tcp::socket socket(io_service);

    socket.async_connect(endpoint, &handle_connect);
    io_service.run();
    return 0;
}
$ em++ main.cpp -o main.js -lboost_system && node main.js
pipe() returning an error as we do not support them

/home/bart/projects/playground/main.js:79
      throw ex;
            ^
5265032

I have a server open in the port 7000 and I was expecting the "connected!" output, but instead got that error. Running in google chrome I get the same error, digging into ASIO source files I have found the root of the problem in boost/asio/detail/impl/pipe_select.interrupter.ipp

void pipe_select_interrupter::open_descriptors()
{
  int pipe_fds[2];
  if (pipe(pipe_fds) == 0)
  ...

So I've created a second test case to see if just that would work:

#include <unistd.h>

int main(int argc, char* argv[])
{
    int fds[2];
    pipe(fds);
    return 0;
}
$ em++ main.cpp -o main.js -lboost_system && node main.js
pipe() returning an error as we do not support them

And I get the same error. And I have a question, is really possible to get Boost ASIO working with emscripten?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions