{"id":17330444,"url":"https://github.com/lxzan/socket","last_synced_at":"2025-03-27T05:44:50.058Z","repository":{"id":117893860,"uuid":"250236993","full_name":"lxzan/socket","owner":"lxzan","description":null,"archived":false,"fork":false,"pushed_at":"2020-03-30T02:01:57.000Z","size":71,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-03-06T14:40:03.276Z","etag":null,"topics":["protocol","socket","tcp"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lxzan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-26T11:14:53.000Z","updated_at":"2024-06-19T06:34:09.101Z","dependencies_parsed_at":"2023-07-08T04:17:52.654Z","dependency_job_id":null,"html_url":"https://github.com/lxzan/socket","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lxzan%2Fsocket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lxzan%2Fsocket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lxzan%2Fsocket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lxzan%2Fsocket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lxzan","download_url":"https://codeload.github.com/lxzan/socket/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245791932,"owners_count":20672669,"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":["protocol","socket","tcp"],"created_at":"2024-10-15T14:51:18.423Z","updated_at":"2025-03-27T05:44:50.039Z","avatar_url":"https://github.com/lxzan.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"### Universal Socket Protocol\n\n- Server\n```go\n    package main\n    \n    import (\n    \t\"github.com/lxzan/socket\"\n    )\n    \n    func main() {\n    \ts := socket.NewServer(\u0026socket.Option{\n    \t\tCryptoAlgo: socket.CryptoAlgo_RsaAes,\n    \t\tPrivateKey: \"example/cert/prv.pem\",\n    \t})\n    \n    \ts.Run(\":9090\", func(client *socket.Client) {\n    \t\tfor {\n    \t\t\tselect {\n                case \u003c-client.PingTicker.C:\n\t\t            client.Ping()\n    \t\t\tcase msg:=\u003c-client.OnMessage:\n    \t\t\t    println(\u0026msg.Body)\n    \t\t\tcase err := \u003c-client.OnError:\n    \t\t\t\tprintln(err.Error())\n    \t\t\t\treturn\n    \t\t\t}\n    \t\t}\n    \t})\n    }\n\n```\n\n\n- Client\n```go\npackage main\n\nimport (\n\t\"github.com/lxzan/socket\"\n)\n\nfunc main() {\n\tclient, err := socket.Dial(\"127.0.0.1:9090\", \u0026socket.Option{\n\t\tCryptoAlgo: socket.CryptoAlgo_RsaAes,\n\t\tPublicKey:  \"example/cert/pub.pem\",\n\t})\n\tif err != nil {\n\t\tprintln(err.Error())\n\t\treturn\n\t}\n\n\t_, err = client.WriteMessage(socket.TextMessage, nil, []byte(\"hello world!\"))\n\tif err != nil {\n\t\tprintln(err.Error())\n\t}\n\n\tfor {\n\t\tselect {\n\t\tcase msg := \u003c-client.OnMessage:\n\t\t\tprintln(string(msg.Body))\n\t\tcase err := \u003c-client.OnError:\n\t\t\tprintln(err.Error())\n\t\t\treturn\n\t\t}\n\t}\n}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flxzan%2Fsocket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flxzan%2Fsocket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flxzan%2Fsocket/lists"}