I've use common internet address like '
192.168.0.104:7014' and connect
to socket in this way:
int flags;
if ((flags = fcntl(socketId, F_GETFL, 0)) < 0) {
abort();
}
if (fcntl(socketId, F_SETFL, flags | O_NONBLOCK) < 0) {
abort();
}
if (socketId >= 0) {
if (connect(socketId, aip->ai_addr, aip->ai_addrlen) < 0) {
if (errno != EINPROGRESS) {
return false;
}
}
return;
}
abort();
After socket is connected I send and receive data in this way:
fd_set fdr;
fd_set fdw;
int res;
FD_ZERO(&fdr);
FD_ZERO(&fdw);
FD_SET(loader->socketId, &fdr);
FD_SET(loader->socketId, &fdw);
res = select(64, &fdr, &fdw, NULL, NULL);
and then I use write(socketId, buf, num) or read(socketId, buf, num)
depends on flags and protocol logic.
This socket code will work in native envrinoment on linux. So I can
test client/server communication through native tools (debugger).
After that when client and server works fine I go to next step,
running websockfiy. For example native server works on port 7014, then
I start proxing this port with websockify to 7015:
websockify -v
192.168.0.104:7014 192.168.0.104:7015
Emscripten version will work on 7015 port (you should connect to 7015
in emscripten version and to 7014 in native version). Usually this
steps is enough to get worked solution.
P.S. For nonblocking mode is correct to get EINPROGRESS it's expected behaviour.
>>>>> an email to
emscripten-disc...@googlegroups.com.
>>
emscripten-disc...@googlegroups.com.
> You received this message because you are subscribed to the Google Groups
> "emscripten-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
emscripten-disc...@googlegroups.com.