Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
flexus-net
Advanced tools
net
API in Chrome and Windows AppsThis module lets you use the Node.js net
module API in Chrome Packaged Apps and Windows Universal Apps.
This is just a simple wrapper module that makes lifes easier when installing Node.js net
module with JSPM for usage in browser-like app enviroments. Namely in Chrome Packages Apps and Windows Universal Apps.
Chrome provides quirky and overly complex chrome.sockets.tcp
API for TCP socket communication which is wrapped by wonderful module chrome-net
to provide the same API as Node.js net
. The same goes for Windows and it's Windows.Networking.Sockets.StreamSocket
and StreamSocketListener
and the module winrt-net
.
And flexus-net
basically just wraps chrome-net
and winrt-net
.
And it also works with NWJS where the native Node net
is used as expected.
jspm install npm:flexus-net
winrt-net
to net
in your SystemJS/JSPM config fileJSPM has it's own module that gets installed whenever you or your dependecy uses net
module. And it does next to nothing because browsers don't do TCP.
In JSPM config file there is property map
with names and mappings of all modules. This is an example of JSPM 0.17 jspm.config.js
map: {
"winrt-net": "npm:winrt-net@1.0.0",
"events": "github:jspm/nodelibs-events@0.2.0-alpha",
"process": "github:jspm/nodelibs-process@0.2.0-alpha",
...
you change the name like so
map: {
"net": "npm:winrt-net@1.0.0",
...
and that forces JSPM to load this module whenever there is require('net')
or import net from 'net'
in your code or dependencies. Now you can write your app with net
module like you would in Node and JSPM handles picking the right module for given enviroment. When runnig in Chrome App the chrome-net
is used, in Windows App the winrt-net
is used or when running NWJS or in Node (using JSPM run path_to_your.js
) the native module is used.
Example TCP client:
import net from 'net';
import net from 'net';
var port = 22112;
var server = net.createServer(function(socket) {
console.log('connection', socket.remoteAddress + ":" + socket.remotePort);
socket.on('data', function (data) {
console.log(data.toString())
})
})
.listen(port)
.on('listening', function () {
console.log('listening')
});
Example TCP server:
import net from 'net';
var client = net.connect(22112, 'localhost')
client.write('Hello server')
client.on('data', function (data) {
console.log('received data', data.toString());
})
Or you can skip step 2) and just use import net from 'flexus-net';
See nodejs.org for full API documentation: net
This project was built for and tested using JSPM.
I'm not using browserify nor do I know how to set up a project for it and currently I don't have enough time to look into it now. So I don't know if this module works in browserify but I'll gladly accept any contributions towards this cause.
Feross Aboukhadijeh, John Hiesey & Jan Schä for creating chrome-net
and Guy Bedford for JSPM
FAQs
Deprecated, to be deleted
We found that flexus-net demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.