Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

spox-spockets

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spox-spockets

  • 0.0.6
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

== Spockets ==

Spockets is a simple library for dealing with multiple sockets. You supply a socket, and one or more blocks to execute, and Spockets will make sure those blocks get executed when something comes in over the wire. It's just that simple.

There is one requirement for spockets and that is the ActionPool. This just allows spockets to use a thread pool for executing blocks so you don't end up having to wait on slow blocks. You can even provide your own pool for spockets to use, so all the action can stay in one local pool.

install (stable):

gem install spockets

install (unstable):

gem sources -a http://gems.github.com
gem install spox-spockets

or

git clone http://github.com/spox/spockets.git
cd spockets
gem build spockets.gemspec
gem install ./

It has RDocs. They are short, but will be helpful and you should really consider giving them a look. If you want to view them online, you can see them here:

http://dev.modspox.com/~sine/spockets

There is also a trac site. It has examples as well as a bug tracker. It's located at:

http://dev.modspox.com/trac/spockets

Examples are usually helpful, so here we go:

Code:

require 'socket'
require 'spockets'
spockets = Spockets::Spockets.new

se = TCPServer.new(3000)
loop do
    s = se.accept
    puts "Socket: #{s}"
    spockets.add(s){|string| puts "#{s}: #{string}" }
end
sleep

Connecting:

> telnet 192.168.0.95 3000
Trying 192.168.0.95...
Connected to 192.168.0.95.
Escape character is '^]'.
goodbyeworld
^]
telnet> quit
Connection closed.

> telnet 192.168.0.95 3000
Trying 192.168.0.95...
Connected to 192.168.0.95.
Escape character is '^]'.
foobar
complete
^]
telnet> quit
Connection closed.

Output:

Socket: #<TCPSocket:0x98ec5ac>
Socket: #<TCPSocket:0x98ec37c>
#<TCPSocket:0x98ec37c>: foobar
#<TCPSocket:0x98ec5ac>: goodbyeworld
#<TCPSocket:0x98ec37c>: complete

FAQs

Package last updated on 10 Aug 2014

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc