Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kevinresol/hxuv
libuv bindings for Haxe
https://github.com/kevinresol/hxuv
async haxe libuv
Last synced: about 2 months ago
JSON representation
libuv bindings for Haxe
- Host: GitHub
- URL: https://github.com/kevinresol/hxuv
- Owner: kevinresol
- Created: 2018-12-02T09:12:50.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-08-22T08:44:27.000Z (over 4 years ago)
- Last Synced: 2024-10-19T02:04:30.810Z (4 months ago)
- Topics: async, haxe, libuv
- Language: Haxe
- Homepage:
- Size: 24.4 KB
- Stars: 14
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# hxuv [![Build Status](https://travis-ci.com/kevinresol/hxuv.svg?branch=master)](https://travis-ci.com/kevinresol/hxuv)
libuv bindings for Haxe
## Philosophy
This library targets to express unopinionatedly the libuv api in a Haxe fashion (e.g. managed memory allocation, GC-friendly, allow closures, etc). So there should be 1-to-1 mapping for each API.
## Documentation
The original libuv documentation should generally apply. However, function signatures might be slightly different from the original in order to fit the Haxe language.
## Supported targets
- C++, requires the [`linc_uv`](https://github.com/kevinresol/linc_uv) library
(possible to support other targets in the future)
## Example
```haxe
// create a echo tcp server
var server = Tcp.alloc();
server.bind('0.0.0.0', 7000, 0);
server.listen(128, function(_) {
var client = Tcp.alloc();
server.accept(client);
client.readStart(function(status, bytes) {
if(bytes != null) client.write(bytes, function(_) trace('echoed')); // echo
else client.close(function() trace('closed')); // client ended
});
});// connect to the server, send a string and print the echo from server
var tcp = Tcp.alloc();
tcp.connect('127.0.0.1', 7000, function(status) {
tcp.write(Bytes.ofString('Hello World!'), function(_) trace('written')); // write to server
tcp.shutdown(function(status) trace('shutdown')); // close the outgoing stream
tcp.readStart(function(status, bytes) {
if(bytes != null) trace(bytes.toString());
else tcp.close(function() trace('closed')); // close the tcp socket
});
});
```## Contributions Welcome
- Complete the API
- Support other targets