I've use linux sockets with emscripten. They work as in native code except
one thing - they should be async. So if you app use async socket then it
should work out the box. Ofcourse you should wrap server socket with
websockify it's work like a charm.

5 дек. 2017 г. 8:21 ДП пользователь "Mark Sibly" <[email protected]>
написал:

> Hi,
>
> I am completely  new to emscipten sockets and am wondering how they work
> and what to expect.
>
> I understand they are built on top of websockets, but I always thought
> websockets were SendMsg/RecvReply based - how does that work?
>
> Do you have to use threads if you want to 'block' on an emscripten socket
> without blocking the entire app? Is this recommended or is it best to just
> 'poll' via, say, ioctlsocket with FIONREAD. Can you poll with select?
>
> Should I at least be able to connect to TCP port 80 of my http website? I
> have so far been unable to perform a simple connect and wonder if it's even
> possible? I'm not expecting to be able to perform an http GET - although
> perhaps that is possible?
>
> My connect code is ipv6-ish, ie:
>
>  int _connect( const char *hostname,const char *service ){
>
> addrinfo hints;
> memset( &hints,0,sizeof( hints ) );
>
> hints.ai_family=AF_UNSPEC;
> hints.ai_socktype=SOCK_STREAM;
> hints.ai_protocol=IPPROTO_TCP;
> if( hostname && !hostname[0] ) hostname=0;
>
> addrinfo *pres=0;
> if( ::getaddrinfo( hostname,service,&hints,&pres ) ) return -1;
> int sock=-1;
> for( addrinfo *res=pres;res;res=res->ai_next ){
> sock=::socket( res->ai_family,res->ai_socktype,res->ai_protocol );
> if( sock==-1 ) continue;
>
> if( !connect( sock,res->ai_addr,res->ai_addrlen ) ) break;
> ::closesocket( sock );
> sock=-1;
> }
> freeaddrinfo( pres );
> return sock;
> }
>
> This works on windows, macos and linux (ie: I can connect any TCP port 80)
> but not emscripten - the connect always fails. Should I revert to the
> pre-ipv6 way of connecting? I did give this a quick try but with no luck.
>
> Any clues most welcome!
>
> Bye,
> Mark Sibly
>
>
>
>
> --
> 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 [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to