| 1 |
# mruby-socket |
| 2 |
|
| 3 |
"mruby-socket" mrbgem provides BSD socket interface for mruby. |
| 4 |
API is compatible with CRuby's "socket" library. |
| 5 |
|
| 6 |
## Example |
| 7 |
|
| 8 |
```sh |
| 9 |
% vi kame.rb |
| 10 |
s = TCPSocket.open("www.kame.net", 80) |
| 11 |
s.write("GET / HTTP/1.0\r\n\r\n") |
| 12 |
puts s.read |
| 13 |
s.close |
| 14 |
|
| 15 |
% mruby kame.rb |
| 16 |
HTTP/1.1 200 OK |
| 17 |
Date: Tue, 21 May 2013 04:31:30 GMT |
| 18 |
... |
| 19 |
``` |
| 20 |
|
| 21 |
## Requirement |
| 22 |
|
| 23 |
- [mruby-io](../mruby-io) mrbgem |
| 24 |
- [iij/mruby-mtest](https://github.com/iij/mruby-mtest) mrbgem to run tests |
| 25 |
- system must have RFC3493 basic socket interface |
| 26 |
- and some POSIX API... |
| 27 |
|
| 28 |
## TODO |
| 29 |
|
| 30 |
- add missing methods |
| 31 |
- write more tests |
| 32 |
- fix possible descriptor leakage (see XXX comments) |
| 33 |
- `UNIXSocket#recv_io` `UNIXSocket#send_io` |
| 34 |
|
| 35 |
## License |
| 36 |
|
| 37 |
Copyright (c) 2013 Internet Initiative Japan Inc. |
| 38 |
Copyright (c) 2017 mruby developers |
| 39 |
|
| 40 |
Permission is hereby granted, free of charge, to any person obtaining a |
| 41 |
copy of this software and associated documentation files (the "Software"), |
| 42 |
to deal in the Software without restriction, including without limitation |
| 43 |
the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 44 |
and/or sell copies of the Software, and to permit persons to whom the |
| 45 |
Software is furnished to do so, subject to the following conditions: |
| 46 |
|
| 47 |
The above copyright notice and this permission notice shall be included in |
| 48 |
all copies or substantial portions of the Software. |
| 49 |
|
| 50 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 51 |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 52 |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 53 |
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 54 |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 55 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 56 |
DEALINGS IN THE SOFTWARE. |