{"id":19034627,"url":"https://github.com/shannah/cn1sockets","last_synced_at":"2025-04-23T17:46:43.633Z","repository":{"id":12806120,"uuid":"15480977","full_name":"shannah/CN1Sockets","owner":"shannah","description":"Codenameone Sockets Library ","archived":false,"fork":false,"pushed_at":"2021-10-25T15:23:33.000Z","size":23386,"stargazers_count":2,"open_issues_count":3,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-18T04:12:17.614Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","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/shannah.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}},"created_at":"2013-12-27T20:03:11.000Z","updated_at":"2025-01-20T09:02:13.000Z","dependencies_parsed_at":"2022-09-17T00:13:06.796Z","dependency_job_id":null,"html_url":"https://github.com/shannah/CN1Sockets","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shannah%2FCN1Sockets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shannah%2FCN1Sockets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shannah%2FCN1Sockets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shannah%2FCN1Sockets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shannah","download_url":"https://codeload.github.com/shannah/CN1Sockets/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250484809,"owners_count":21438312,"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-11-08T21:46:12.679Z","updated_at":"2025-04-23T17:46:43.615Z","avatar_url":"https://github.com/shannah.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Codename Sockets Library\n\nThis library was started as an attempt to add sockets support to Codename One.  I have so far created native interfaces for iOS, Android, Blackberry, JavaSE and J2ME.\n\n## Installation\n\nInstall through Codename One Settings \u003e Extensions.  Or manually install with following steps:\n\n\n1. Copy the [CN1Sockets.cn1lib](bin/CN1Sockets.cn1lib) library into your application's `lib` directory.\n2. Right click on your project's icon in the Netbeans project explorer, and select \"Refresh Libs\"\n\n## Usage Example\n\n~~~~\n\nimport ca.weblite.codename1.net.Socket;\n// .. rest of imports\n\n\n// … your application's main class\n\n    public void start(){\n        lbl = new Label(\"Result here\");\n        Form hi = new Form(\"Socket Tester\");\n        Button btn = new Button(\"Run Test\");\n        btn.addActionListener(new ActionListener(){\n\n            public void actionPerformed(ActionEvent evt) {\n                Display.getInstance().callSerially(new Runnable(){\n\n                    public void run() {\n                        runSocketTests();\n                    }\n                    \n                });\n            }\n            \n        });\n        \n        hi.addComponent(btn);\n        hi.addComponent(lbl);\n        hi.show();\n    }\n    \n    \n    public void runSocketTests(){\n        try {\n            if ( Socket.isSocketSupported() ){\n                Socket sock = new Socket(\"example.com\", 80);\n                sock.getOutputStream().write(\"GET / HTTP/1.0\\r\\nHost: example.com\\r\\n\\r\\n\".getBytes());\n\n                String result = Util.readToString(sock.getInputStream());\n                    // NOTE:  Util.readToString() closes the input stream automatically.\n                    // Don't use it if you need to keep the socket open.  Use\n                    // another mechanism to read the stream.\n                lbl.setText(result);\n                //sock.close();\n                Log.p(result);\n            } else {\n                lbl.setText(\"Sockets not supported\");\n                Log.p(\"Sockets not supported\");\n            }\n        } catch ( Exception ex){\n            Log.p(\"We have an error\");\n            Log.e(ex);\n            \n        }\n    }\n\n// …\n\n~~~~\n\n\n## To Do\n\n1. Try out the J2ME and Blackberry ports.  They are there but I have never tested them so they may need some tweaking.\n2. Stress test.  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshannah%2Fcn1sockets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshannah%2Fcn1sockets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshannah%2Fcn1sockets/lists"}