Ok - I've detected the small difference: There is a terminating slash in 
the error message reported by Firefox 'Firefox cannot establish the 
connection to ws://127.0.0.1:9338*/'* <http://127.0.0.1:9338>
If I add that to the java script version I also get connectivity problems 
here...

Den fredag den 20. januar 2017 kl. 11.13.50 UTC+1 skrev Thomas Arnbjerg:
>
> I've created a server component listening for web socket communication on 
> port 9338 using libwebsockets.
>
> If i instantiate a client side web socket as 'var ws = new 
> WebSocket("ws://127.0.0.1:9338");' the communication works like a charm 
> and I can send data from the client to the server.
>
> If I instantiate a socket in c++ as shown below:
>
> serverFileDescriptor = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP);
>     struct sockaddr_in serverSocketAddress;
>     memset (&serverSocketAddress, 0, sizeof(serverSocketAddress));
>     serverSocketAddress.sin_family = AF_INET;
>     serverSocketAddress.sin_port = htons (9338);
>     if (inet_pton (AF_INET, "127.0.0.1",
>            &serverSocketAddress.sin_addr) != 1)
>     {
>       std::cout << "*** inet_pton failed: " << __FILE__ << ", " << 
> __LINE__ << std::endl;
>       return false;
>     }
>
>     int res = connect (serverFileDescriptor,
>                (struct sockaddr *) &serverSocketAddress,
>                sizeof(serverSocketAddress));
>     if (res == -1 && errno != EINPROGRESS)
>     {
>       std::cout << "*** connect failed: " << __FILE__ << ", " << __LINE__ 
> << std::endl;
>       return false;
>     }
>     std::cout<<"Connection established to 127.0.0.1:9338"<<std::endl;
>  
> - everything succeeds and it see 'Connection established to 127.0.0.0:9338' 
> but Firefox reports 'Firefox cannot establish the connection to ws://
> 127.0.0.1:9338' and the 'emscripten_set_socket_error_callback' function 
> is called with the error 'ECONNREFUSED' and code 111.
>
> I've done the following call back registrations:
>  emscripten_set_socket_error_callback ((void*) "Socket 
> Error",ServerConnection::socketErrorCallback);
>   emscripten_set_socket_open_callback ((void*) "Connection 
> open",ServerConnection::socketOpenCallback);
>   emscripten_set_socket_message_callback ( (void*) "Data Available", 
> ServerConnection::socketDataAvailableCallback);
>
> - and the 'emscripten_set_socket_open_callback' is never called.
>  
> I'm using emscripten 1.35 on Windows 7.
>
> Can anyone give me a hint on what I'm doing wrong? - or is the assumption 
> that sockets in emscripten are implemented as websockets fundamentally 
> wrong?
>
>

-- 
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