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

ionian

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ionian

  • 0.8.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Ionian

Gem Version

A Ruby library to simplify interaction with IO streams. This includes network sockets, file sockets, and serial streams like the console and RS232. Features regular expression matching and notification of received data.

Supported Ruby Versions

  • MRI >= 2.0.0

Installation

gem install ionian

Issues, Bugs, Feature Requests

Any bugs and feature requests should be reported on the GitHub issue tracker:

https://github.com/amclain/ionian/issues

Pull requests are preferred via GitHub.

Mercurial users can use Hg-Git to interact with GitHub repositories.

Code Examples

Creating A Socket

socket = Ionian::Socket.new host: '127.0.0.1', port: 23

Sending And Receiving Data

socket = Ionian::Socket.new host: 'google.com', port: 80
socket.write "GET / HTTP/1.1\r\n\r\n"
socket.read_match { |match| p match; puts '' }

Match Expressions And Named Captures

# A simple IRC client.

socket = Ionian::Socket.new \
  host: 'chat.freenode.net:6667',
  # Break up the matches into named captures so it's easier
  # to sort through the server's responses.
  expression: /:(?<server>.*?)\s*:(?<msg>.*?)[\r\n]+/

# Log on to IRC and send a message.
socket.write "NICK ionian-demo\r\nUSER ionian-demo ionian-demo chat.freenode.net :ionian-demo"
socket.write "PROTOCL NAMESX\r\n"
socket.write "JOIN #ionian-demo\r\n"
socket.write "PRIVMSG #ionian-demo :this is a test\r\n"


loop do
  socket.read_match do |match|
  	# Print the body of the server's responses.
    puts match.msg
    
    # Exit when the server has caught up.
    exit if match.msg.include? 'End of /NAMES list.'
  end
end

Simple Server

host = 'localhost:5000'

server = Ionian::Server.new interface: host do |client|
  # Greet the connected client.
  client.write "Welcome! You are connected to the server.\n"
end

socket = Ionian::Socket.new host: host
# Retrieve the greeting message.
puts socket.read_all

FAQs

Package last updated on 12 Feb 2015

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