I might be wrong but I don't think that's possible. First, you can't expose a TCP-compatible socket in browsers (Emscripten's TCP API is an emulation wrapper over WebSockets, which are not protocol-compatible with 'raw' TCP).
WebSocket in the browser can only implement a client interface (e.g. it cannot accept incoming connections, only connect to a 'native' WebSocket server).
WebRTC data channels might allow to implement something that looks like a server running in a browser (because it's a peer-to-peer connection system), but you couldn't connect with a regular TCP or WebSocket client, only with a client that also uses the WebRTC data channel protocol.