Skip to content

Sockets and files

A browser cannot open TCP connections. Each flash.net.Socket goes instead through a WebSocket relay that you run, for example websockify, which carries binary frames to the server:

configure({
socketProxy: [{ host: "server.example", port: 9000, proxyUrl: "wss://relay.example/9000" }],
// or a function: (host, port) => `wss://relay.example/${host}/${port}`, null to refuse
});

A player you set up yourself takes socket: from webSocketSocketHost(urlFor) (@swf2es/player-hosts/websocket). In node, nodeSocketHost() (@swf2es/player-hosts/node) connects directly, and so does the desktop app, through its main process; both send each write at once, without Nagle’s algorithm, unless an AIR SWF set tcpNoDelay to false before it connected. An embedder with a transport of its own gives it as configure({ sockets }); its connect(host, port, events, options) gets options.noDelay where the SWF set tcpNoDelay.

An AIR application’s air.net.WebSocket uses the page’s own WebSocket. An embedder whose page may not connect, as the desktop app’s, whose main process holds the connections, gives a WebSocketHost of its own as configure({ webSockets }): its connect(url, protocols, events) opens a connection, tells events its open, message, close and error, and returns its send and close.

FileReference and FileReferenceList use the browser’s file chooser. Saving uses the File System Access picker where available, or a Blob download; uploads and downloads use the player’s host fetch. A custom embedder can supply configure({ fileHost }) (FileHost from @swf2es/player), or set fileHost: null to make dialogs cancel. The desktop app supplies native dialogs. Browser dialogs require a recent user click or keypress.