Created
October 14, 2014 14:15
-
-
Save bbozo/0c55f168e4fe6fb021fd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'celluloid/io' | |
require 'http' | |
class Client | |
include Celluloid::IO | |
def transmit | |
HTTP.get('http://127.0.0.1:1337', socket_class: Celluloid::IO::TCPSocket) | |
end | |
end | |
pool = Client.pool | |
10.times.map{ pool.future.transmit }.map(&:value) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'celluloid/io' | |
require 'http' | |
class Client | |
include Celluloid::IO | |
def transmit | |
HTTP.get('http://127.0.0.1:1337', socket_class: Celluloid::IO::TCPSocket) | |
end | |
end | |
client = Client.new | |
10.times.map{ client.future.transmit }.map(&:value) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
var count = 0; | |
http.createServer(function (req, res) { | |
count = count + 1; | |
console.log('Parallel client opens connection ' + count); | |
req.connection.on('close',function(){ | |
count = count - 1; | |
console.log('Parallel client closes connection ' + count); | |
}); | |
setTimeout(function(){ | |
res.writeHead(200, {'Content-Type': 'application/json'}); | |
res.end('{"foo":"boo"}'); | |
}, 2000); | |
}).listen(1337, '127.0.0.1'); | |
console.log('Server running at http://127.0.0.1:1337/'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment