New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
encountered with problem when Porting UDP socket communication c code using emscripten #5196
Comments
It is unfortunately not possible to send UDP datagrams from web browsers. The BSD sockets code fakes the API and makes the socket attempt to connect to a websockets server, so your listening endpoint will need to be a websockets communicating server. There exists projects such as If you need UDP style communication, then it is possible to utilize WebRTC data channels, which gives unreliable and unordered transmission. However that is also connectionful, and the browser must connect to a WebRTC server and cannot talk to an arbitrary UDP listening socket. Do you need to connect to an UDP server, or can you migrate to a Websocket or WebRTC data channels server? If UDP server is really required, check out something like https://dimitrisfousteris.wordpress.com/2014/12/07/websocket-udp-proxy-with-node-js/ which is like websockify but for UDP. |
Thanks to you precious suggestions,why I need to connect browser to UDP endpoint?I want to create p2p videostream channal between the webbrowser and our device,so the plan which converts websocket stream and UDP stream is not possible,because compared with this plan,I have better choice to connect webbrowser and devices using TCP channel ( and websocket),between both methods need to connect transserver and device!so in a few words,since browser doesn't support UDP natively,to create p2p stream channel between webbrowser and device,the only choice is to use webrtc,do you agree with me? |
That makes sense. I have not used WebRTC for video, though perhaps https://www.tutorialspoint.com/webrtc/webrtc_video_demo.htm and https://www.html5rocks.com/en/tutorials/webrtc/basics/ can help towards an implementation here? |
Try this: |
This issue has been automatically marked as stale because there has been no activity in the past 2 years. It will be closed automatically if no further activity occurs in the next 7 days. Feel free to re-open at any time if this issue is still relevant. |
I write simple UDP communicate code using C,just as follows:
Client.c:
Server.c:
now:
compile server:
gcc server.c -o server
then compile client using emcc:
emcc client.c -o client.html
all runs ok,I run server firstly in one linux terminal,and open client.html using Chrome,but I got wrong message:
WebSocket connection to 'ws://172.18.193.73:30000/' failed: WebSocket is closed before the connection is established.
Obviously,emscripten converts udp socket in c language to websocket in javascript,but websocket bases on tcp ,not udp, So the problem is how can I port udp socket syscall to javascript using emscripten?welcome you to talk over with me!
The text was updated successfully, but these errors were encountered: