zhaojh329 / libuwsc

A Lightweight and fully asynchronous WebSocket client library based on libev
MIT License
289 stars 53 forks source link

Build failed on Macos #7

Closed selimanac closed 5 years ago

selimanac commented 5 years ago

Is this lib compatible with MacOS, iOS or Android? I try to build it on MacOS but it fails. Also, is it threat safe?

with '-Wno-misleading-indentation'

error: unknown warning option '-Wno-misleading-indentation'; did you mean '-Wno-binding-in-condition'? [-Werror,-Wunknown-warning-option]

with -Wno-binding-in-condition

uwsc.c:66:12: error: implicit declaration of function 'htobe16' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    code = htobe16(code & 0xFFFF);
           ^
uwsc.c:117:29: error: implicit declaration of function 'be16toh' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        frame->payloadlen = be16toh(buffer_pull_u16(rb));
                            ^
uwsc.c:122:15: error: implicit declaration of function 'be64toh' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        len = be64toh(buffer_pull_u64(rb));
              ^
uwsc.c:122:15: note: did you mean 'be16toh'?
uwsc.c:117:29: note: 'be16toh' declared here
        frame->payloadlen = be16toh(buffer_pull_u16(rb));
                            ^
uwsc.c:421:28: error: implicit declaration of function 'htobe16' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        buffer_put_u16(wb, htobe16(len));
                           ^
uwsc.c:424:28: error: implicit declaration of function 'htobe64' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        buffer_put_u64(wb, htobe64(len));
                           ^
uwsc.c:462:28: error: implicit declaration of function 'htobe16' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        buffer_put_u16(wb, htobe16(len));
                           ^
uwsc.c:465:28: error: implicit declaration of function 'htobe64' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        buffer_put_u64(wb, htobe64(len));
                           ^
uwsc.c:575:36: error: use of undeclared identifier 'SOCK_NONBLOCK'
    sock = tcp_connect(host, port, SOCK_NONBLOCK | SOCK_CLOEXEC, &inprogress, &eai);
                                   ^
uwsc.c:575:52: error: use of undeclared identifier 'SOCK_CLOEXEC'
    sock = tcp_connect(host, port, SOCK_NONBLOCK | SOCK_CLOEXEC, &inprogress, &eai);
                                                   ^
zhaojh329 commented 5 years ago

Yes. It's not compatible with mac os. Maybe you can make a PR to fix it.

selimanac commented 5 years ago

Sorry to hear that. I was planning to use it in the game engine. Thank you. Yes, maybe I can PR but I need a solid solution for now.

selimanac commented 5 years ago

Just for an info... I manage the build it using this: https://gist.github.com/panzi/6856583 and

#ifndef SOCK_NONBLOCK
#include <fcntl.h>
# define SOCK_NONBLOCK O_NONBLOCK
#endif

and changing FD_CLOEXEC But unfortunately can't connect to "ws://demos.kaazing.com:80/echo" ... uwsc.c:696) tcp_connect failed: Protocol not supported