Skip to content
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

TCP Socket #5

Closed
Gozala opened this issue May 16, 2018 · 4 comments
Closed

TCP Socket #5

Gozala opened this issue May 16, 2018 · 4 comments

Comments

@Gozala
Copy link
Contributor

Gozala commented May 16, 2018

In fact there was an effort to standardize TCP and UDP Socket APIs which might be worth pursuing in this context. Firefox has scriptable nsIServerSocket and nsISocketTransportService that could be wrapped and exposed to WebExtensions.

🐞 1247628

@autonome
Copy link
Contributor

@Gozala
Copy link
Contributor Author

Gozala commented Jul 8, 2018

I run into TCPServerSocket bug, starting a server on the port that is already in use does not seem to report an issues but such socket seems to be corrupt. Filed Bug 1474150

@Gozala
Copy link
Contributor Author

Gozala commented Jul 10, 2018

Status update here had being long due, so here it is:

  • I have a TCP Client / Server Socket API #15 that was pretty much exposing existing implementations (made for Firefox OS) that is exposed through TCPServerSocket.webidl / TCPSocket.webidl
  • Unfortunately as I was testing that implementation I discovered Bug 1474150 - starting a server bound to a port that is already in use does not seem to report an issues and socket just seems to not work. There might be more issues along those lines.
  • I end up working on alternative implementation Alternative TCP API implementation based on XPCOM #17 that pretty much ports TCPSocket.cpp / TCPServerSocket.cpp (that are implementations of above mentioned webidl's) to JS + all the same stuff to expose this to add-ons.
  • TCP API unlike other APIs had unique challenge (it’s surprising other APIs were free of it) of having to deal with references across two privileged / unprivileged JS environments. More specifically for connections received on server socket we don't want to store references in privileged context as we won't know when to release them.
  • GC issue lead me to spend more time figuring out how we could pass handles (which are objects rather than primitives) to the non-privileged JS so that privileged one could use them as keys in weak map. Which with some help I was able to work out.
  • Non primitive handles also provides an opportunity for a nicer API that does not require defining everything as static method. Although I'm not entirely how much do people care, discussion in File System API #8 suggests static APIs were more desired.
  • Ideally APIs will just match w3 tcp-udp-sockets, but again lack of Readable / Writable does not make it viable option for now.

@Gozala
Copy link
Contributor Author

Gozala commented Jul 23, 2018

Version with AsyncIterators has landed, all the followup work lie Readable streams etc.. should be tracked in dedicated issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants