{"id":38686484,"url":"https://github.com/gen-iot/liblpc","last_synced_at":"2026-01-17T10:24:36.010Z","repository":{"id":57486236,"uuid":"198447108","full_name":"gen-iot/liblpc","owner":"gen-iot","description":"Golang high performance, event-driven, asynchronous I/O ","archived":false,"fork":false,"pushed_at":"2019-12-19T13:00:39.000Z","size":130,"stargazers_count":4,"open_issues_count":1,"forks_count":2,"subscribers_count":0,"default_branch":"v2","last_synced_at":"2025-08-13T21:28:53.875Z","etag":null,"topics":["epoll","event-driven","high-performance","kqueue","networking"],"latest_commit_sha":null,"homepage":"","language":"Go","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/gen-iot.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":"2019-07-23T14:26:56.000Z","updated_at":"2022-11-09T18:04:03.000Z","dependencies_parsed_at":"2022-09-01T22:31:06.588Z","dependency_job_id":null,"html_url":"https://github.com/gen-iot/liblpc","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/gen-iot/liblpc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gen-iot%2Fliblpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gen-iot%2Fliblpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gen-iot%2Fliblpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gen-iot%2Fliblpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gen-iot","download_url":"https://codeload.github.com/gen-iot/liblpc/tar.gz/refs/heads/v2","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gen-iot%2Fliblpc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28506440,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T06:57:29.758Z","status":"ssl_error","status_checked_at":"2026-01-17T06:56:03.931Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["epoll","event-driven","high-performance","kqueue","networking"],"created_at":"2026-01-17T10:24:35.900Z","updated_at":"2026-01-17T10:24:35.994Z","avatar_url":"https://github.com/gen-iot.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# liblpc\n\nHigh performance async network io library\n\n![go report](https://goreportcard.com/badge/github.com/gen-iot/liblpc)\n![license](https://img.shields.io/badge/license-MIT-brightgreen.svg)\n[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/gen-iot/liblpc)\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat)](https://github.com/gen-iot/liblpc/pulls)\n[![Ask Me Anything !](https://img.shields.io/badge/Ask%20me-anything-1abc9c.svg)](https://github.com/gen-iot/liblpc/issues)\n\n## First\nif you have **any** good feature suggestions or bug fixed ,\n **any** [Pull Request](https://github.com/gen-iot/liblpc/pulls) or [Issues](https://github.com/gen-iot/liblpc/issues) are **welcome**!\n \n## Usage\n\n\n```bash\n# install liblpc v2\ngo get -u github.com/gen-iot/liblpc/v2@latest\n```\n\n```go\n// import \nimport \"github.com/gen-iot/liblpc/v2\"\n```\n\n## Overview\n\n- World Based On **Event Loop** 😎\n- UnBuffered/Buffered Stream 🚀\n- Timers: IO Timeout, Delay... ⏰\n- DNS Resolve 🌐\n- Lots Of Unix Socket API Toolbox 🔧\n- Thread(*Goroutine*) Safe! 👍\n\n## Backend\n\n|  Platform  | Backend |     Support      |\n|:----------:|:-------:|:----------------:|\n|   Linux family   |  Epoll  | Done 🎉  |\n|   mac OS\u003cbr\u003e(BSD family)     | Kqueue  | Done 🎉 |\n|  Windows   |  IOCP   |    Maybe Never... 😢    |\n| POSIX Like |  Poll   |    Maybe Never... 🥺 \u003cbr\u003ewe already have `epoll`    |\n| POSIX Like | Select  |    Coming Soon 🤡   |\n\n`liblpc` using interface `Poller` and `Watcher` as abstraction for any backend.\n\n## Getting Started\n\n### Create Pure EventLoop:\n\n```go\nloop,err := liblpc.NewEventLoop()\nstd.AssertError(err, \"new pure event loop\")\n```\n\n### Create IO EventLoop:\n\n```go\nloop, err := liblpc.NewIOEvtLoop(1024 * 4)\nstd.AssertError(err, \"new io event loop\")\n```\n\n### Loop Lifecycle:\n\n**exit a loop**\n```go\n// just call loop.Break in anywhere\nloop.Break()\n```\n📌**Loop.'Close' can't stop a loop but Loop.'Break' can.**\n\n📌**Loop.'Close' use to cleanup a loop**\n\n**Cleanup a loop**\n\n```go\nloop ,err := liblpc.NewEventLoop()\nstd.AssertError(err, \"new event loop\")\ndefer loop.Close()\n```\n\n**Run loop synchronously**\n```go\n// block until break loop called\nloop.Run()\n```\n\n**Run loop asynchronously😂😂😂**\n```go\ngo func(){ loop.Run() }()\n```\n\n### Create Listener:\n\n```go\n// create listen fd first!\nlistenerFd, err := liblpc.NewListenerFd(\n  \"127.0.0.1:12345\", // serve at\n  1024,              // backlog\n  true,              // enable reuse addr\n  true,              // enable reuse port\n)\nstd.AssertError(err, \"new listener fd\")\n// new listener\nlistener := liblpc.NewListener(loop, int(listenerFd), onAccept)\nlistener.Start()\n```\n\n### Accept New Conn Stream:\n\n```go\n// 📌Note: in accept callback\nstream := liblpc.NewConnStream(\n  ln.Loop().(*liblpc.IOEvtLoop), // cast Loop to IOEventLoop \n  newFd,                         // incoming fd\n  onStreamRead,                  // read callback\n  )\nstream.SetOnClose(onStreamClose) // register close callback\nstream.Start()\n```\n\n### Create Client Stream:\n\n```go\ncliFd, err := liblpc.NewConnFd(addr)\nstd.AssertError(err, \"new client fd failed\")\nstream := liblpc.NewConnStream(loop, int(cliFd), nil)\nstream.SetOnConnect(func(sw liblpc.StreamWriter, err error) {\n  sw.Write([]byte(\"hello world!\"), true)\n})\nstream.SetOnClose(func(sw liblpc.StreamWriter, err error) {\n  log.Println(\"client close :\", err)\n  // break loop...\n  loop.Break()\n})\nstream.Start()\n```\n📌**Stream.'Close' is safe to invoke multi times**\n\n📌**Anytime you can't find out whether if Stream is 'Closing' or really been 'Closed',Just invoke  Stream.'Close'**\n\n\n### Example: Simple **Read/Write/Close** \n\n```go\n\npackage main\n\nimport (\n  \"github.com/gen-iot/liblpc\"\n  \"github.com/gen-iot/std\"\n  \"log\"\n)\n\nfunc onStreamRead(sw liblpc.StreamWriter, data []byte, len int) {\n  // print client data in string format\n  log.Println(\"on read:\", string(data[:len]))\n  _ = sw.Close()\n}\n\nfunc onStreamClose(sw liblpc.StreamWriter, err error) {\n  log.Println(\"conn closed,err:\", err)\n  _ = sw.Close() // close remote client\n}\n\nfunc onAccept(ln *liblpc.Listener, newFd int, err error) {\n  if err != nil {\n    log.Printf(\"listener got error:%v\\n\", err)\n    return\n  }\n  stream := liblpc.NewConnStream(\n    ln.Loop().(*liblpc.IOEvtLoop), // cast Loop to   IOEventLoop \n    newFd,                         // incoming fd\n    onStreamRead,                  // read callback\n    )\n  stream.SetOnClose(onStreamClose) // register close   callback\n  stream.Start()\n}\n\nfunc simpleClient(loop *liblpc.IOEvtLoop, addr string) {\n  cliFd, err := liblpc.NewConnFd(addr)\n  std.AssertError(err, \"new client fd failed\")\n  stream := liblpc.NewConnStream(loop, int(cliFd), nil)\n  stream.SetOnConnect(func(sw liblpc.StreamWriter, err   error) {\n    sw.Write([]byte(\"hello world!\"), true)\n  })\n  stream.SetOnClose(func(sw liblpc.StreamWriter, err error)   {\n    log.Println(\"client close :\", err)\n    // close itself\n    _ = sw.Close()\n    // break loop...\n    loop.Break()\n  })\n  stream.Start()\n}\n\nfunc main() {\n  loop, err := liblpc.NewIOEvtLoop(1024 * 4)\n  std.AssertError(err, \"new event loop\")\n  defer std.CloseIgnoreErr(loop)\n  // create listen fd first!\n  listenerFd, err := liblpc.NewListenerFd(\n    \"127.0.0.1:12345\", // serve at\n    1024,              // backlog\n    true,              // enable reuse addr\n    true,              // enable reuse port\n  )\n  std.AssertError(err, \"new listener fd\")\n  // new listener\n  listener := liblpc.NewListener(loop, int(listenerFd),   onAccept)\n  defer std.CloseIgnoreErr(listener)\n  listener.Start()\n  // start simple client\n  simpleClient(loop, \"127.0.0.1:12345\")\n  //\n  loop.Run()\n}\n```\n\n\n\n## License\n\nReleased under the [MIT License](https://github.com/gen-iot/liblpc/blob/master/License)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgen-iot%2Fliblpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgen-iot%2Fliblpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgen-iot%2Fliblpc/lists"}