{"id":16366359,"url":"https://github.com/mgartner/motion-unixsocket","last_synced_at":"2025-03-23T02:32:38.844Z","repository":{"id":20653417,"uuid":"23935547","full_name":"mgartner/motion-unixsocket","owner":"mgartner","description":"A Unix domain socket library for Rubymotion.","archived":false,"fork":false,"pushed_at":"2014-09-24T22:17:29.000Z","size":192,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-12T02:46:06.752Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mgartner.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-09-11T21:00:52.000Z","updated_at":"2021-10-04T18:31:14.000Z","dependencies_parsed_at":"2022-08-20T23:40:36.738Z","dependency_job_id":null,"html_url":"https://github.com/mgartner/motion-unixsocket","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgartner%2Fmotion-unixsocket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgartner%2Fmotion-unixsocket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgartner%2Fmotion-unixsocket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgartner%2Fmotion-unixsocket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mgartner","download_url":"https://codeload.github.com/mgartner/motion-unixsocket/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221842687,"owners_count":16890178,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T02:46:09.868Z","updated_at":"2024-10-28T14:46:07.913Z","avatar_url":"https://github.com/mgartner.png","language":"Ruby","readme":"Motion-UNIXSocket [![Code Climate](https://codeclimate.com/github/mgartner/motion-unixsocket/badges/gpa.svg)](https://codeclimate.com/github/mgartner/motion-unixsocket) [![Gem Version](https://badge.fury.io/rb/motion-unixsocket.svg)](http://badge.fury.io/rb/motion-unixsocket)\n=================\n\nRubyMotion doesn't provide the convenient UNIXSocket class for interacting with\nUnix domain sockets. Motion-UNIXSocket is a replacement for UNIXSocket built\non top of C's socket library and Objective-C's NSFileHandle.\n\nInstallation\n------------\n\nAdd this to your Gemfile:\n\n```\ngem \"motion-unixsocket\", \"~\u003e 0.0.1\"\n```\n\nRun bundle install:\n\n```\n$ bundle install\n```\n\nUsage\n-----\n\nYou can communicate with Unix domain sockets synchronously by reading and\nwriting NSData objects.\n\n```ruby\nsock = UNIX::Socket.new('/path/to/socket')\nmsg = \"Put a sock in it!\\n\"\nsock.write(msg.to_data)\n\nresponse = sock.read\nputs NSString.stringWithUTF8String(response.bytes)\n# =\u003e \"Some message sent back.\"\n```\n\nYou can read from the socket asynchronously by passing a block to the constructor.\n\n```ruby\nsock = UNIX::Socket.new('/path/to/socket') do |data|\n  puts data # =\u003e prints and NSData object\nend\n\nmsg = \"Put a sock in it!\\n\"\nsock.write(msg.to_data)\n```\n\nSupport\n-------\n\nI've only tested this gem on OS X.\n\nStatus\n------\n\nThis gem is very young and I'm sure there's some unknown bugs and gotchas. I'll try to fix any issues brought up, but pull requests for bug fixes, optimizations, and API changes are always welcome.\n\nIdeally the UNIX::Socket class would inherit from IO. If anyone knows an example of IO being subclassed properly, please point me in the right direction.\n\nTests\n-----\n\nWriting tests for this was a bit tricky. I ended up using an MRI Ruby process to create a socket server. Each test spawns this simple Unix domain socket server which echos a message sent to it and then closes. The tests check that the value written to the socket via UNIX::Socket (RubyMotion version) is the same as the value read back.\n\nI was unable to get the asynchronous version working in the tests, but it works fine in an application and in the REPL.\n\nLicense\n-------\n\nMIT License\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmgartner%2Fmotion-unixsocket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmgartner%2Fmotion-unixsocket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmgartner%2Fmotion-unixsocket/lists"}