I am very curious to know how sockets will work in webGL version. WebGL only supports WebSockets but we can write TCP socket inside Unity. So, how is it going to work? For mobile, Unity free version does not support sockets, what about webGL?
Definitely TCP socket can not work on web browsers. But they can provide a special class for websocket. So that instead of writing a JS code for websocket and then writing a wrapper in C# to call this JS code, I can directly create WebSocket in C# code which will then compiled to corresponding JS code.
In this way, I can create a framework which uses both TCP and WebSocket and then select one protocol based on the platform. It will be lot easier then.
You can already do that using the simple plugin Jonas made. Perhaps it will get integrated into Unity at some point, so you don’t need to use a plugin, but I imagine it would operate in pretty much the same way. Jonas’s plugin already lets you use a C#-based websocket library in the Editor or in non-WebGL builds, without your high level code needing to know the difference.
It doesn’t really make sense to try to abstract TCP and Websockets under the same banner - they have different API semantics (TCP is stream-based, while Websockets are message-based). It is simpler in general to just use Websockets on all platforms unless you have particular reasons not to (e.g. they have some overhead, like mandatory data scrambling) in which case you need to work out what your requirements are and find or define a protocol that better suits your needs.