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
| int sock = socket(PF_INET, SOCK_STREAM); | |
| bind(sock, addr); | |
| listen(sock); | |
| allsock.add(sock); | |
| while ( 1 ) { | |
| result = select(sock); | |
| if ( result > 0 ) { | |
| int new_sock = accept(sock, &addr); |
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
| int sock = socket(PF_INET, SOCK_STREAM); | |
| bind(sock, addr); | |
| listen(sock); | |
| struct epoll_event ev; | |
| struct epoll_event events[1024]; | |
| int epfd = epoll_create(1024); | |
| ev.events = EPOLLIN; | |
| ev.data.fd = sock; |
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
| use AnyEvent::Socket; | |
| use AnyEvent::Handle; | |
| my $cv = AE::cv; | |
| tcp_server undef, 8000, sub { | |
| my $hdl; | |
| $hdl = AnyEvent::Handle->new( | |
| fh => shift, | |
| on_read => sub { |
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 'rubygems' | |
| require 'eventmachine' | |
| module EchoHandler | |
| def receive_data data | |
| send_data(data) | |
| end | |
| end | |
| EventMachine.run { |
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
| from twisted.internet.protocol import Protocol, Factory | |
| from twisted.internet import reactor | |
| class Echo(Protocol): | |
| def dataReceived(self, data): | |
| self.transport.write(data) | |
| factory = Factory() | |
| factory.protocol = Echo | |
| reactor.listenTCP(8000, factory) |
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
| import eventlet | |
| def handle(fd): | |
| while True: | |
| c = fd.recv(16384) | |
| if not c: break | |
| fd.sendall(c) | |
| server = eventlet.listen(('0.0.0.0', 8000)) | |
| pool = eventlet.GreenPool(size=32768) |
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 net = require('net'); | |
| var server = net.createServer(function (socket) { | |
| socket.on('data', function (data) { | |
| socket.write(data); | |
| }); | |
| }); | |
| server.listen(8000); |
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
| #!/usr/bin/env ruby | |
| require 'rubygems' | |
| require 'net/http' | |
| require 'string-irc' | |
| channels = %w( #test ) | |
| status_file = '/tmp/.ghe-overload' | |
| pcpu_threshold = 80 |
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
| #!/usr/bin/env perl | |
| use strict; | |
| use warnings; | |
| use Linux::Smaps; | |
| @ARGV or die "usage: %0 pid"; | |
| my $pid = shift; | |
| my $pstree = `pstree $pid -p`; |
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 'rake' | |
| require 'rspec/core/rake_task' | |
| hosts = [ | |
| { | |
| :name => 'proxy001.example.jp', | |
| :roles => %w( base proxy ), | |
| }, | |
| { | |
| :name => 'proxy002.example.jp', |