{"id":19441420,"url":"https://github.com/jeffmikels/tcp_client_dart","last_synced_at":"2025-04-14T19:23:16.706Z","repository":{"id":41896229,"uuid":"484858829","full_name":"jeffmikels/tcp_client_dart","owner":"jeffmikels","description":"A simple client for Dart to manage connecting, reconnecting, sending, and receiving data over TCP sockets.","archived":false,"fork":false,"pushed_at":"2022-04-23T21:22:02.000Z","size":9,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T07:51:10.084Z","etag":null,"topics":["client","dart","dartlang","flutter","hacktoberfest","networking","tcp","telnet"],"latest_commit_sha":null,"homepage":"","language":"Dart","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/jeffmikels.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2022-04-23T21:19:51.000Z","updated_at":"2024-03-28T01:49:38.000Z","dependencies_parsed_at":"2022-08-11T20:31:34.130Z","dependency_job_id":null,"html_url":"https://github.com/jeffmikels/tcp_client_dart","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeffmikels%2Ftcp_client_dart","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeffmikels%2Ftcp_client_dart/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeffmikels%2Ftcp_client_dart/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeffmikels%2Ftcp_client_dart/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jeffmikels","download_url":"https://codeload.github.com/jeffmikels/tcp_client_dart/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248943471,"owners_count":21186969,"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":["client","dart","dartlang","flutter","hacktoberfest","networking","tcp","telnet"],"created_at":"2024-11-10T15:35:23.120Z","updated_at":"2025-04-14T19:23:16.685Z","avatar_url":"https://github.com/jeffmikels.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Features\n\nThis library provides a single class `TcpClient` that manages connecting, disconnecting, and automatically reconnecting to another machine `TCP`. Received data is exposed as a `Stream` that remains consistent even if the underlying socket disconnects and reconnects.\n\nAdditionally, the connection status of the socket is also exposed as a `Stream`.\n\nThis class makes it easy to send and receive data as bytes or strings, and it optionally can wrap the send functions in a `Future` that will resolve with the server's response.\n\nAdditionally, this class allows you to specify a `terminator` as either bytes or strings to identify\nwhen a full 'message' has been received or not. For example, standard Telnet clients use `\\r\\n` as the string that separates messages from each other, and `HTTP` uses `\\r\\n\\r\\n` to separate different parts of a message. Each `TCP` protocol should define its own terminator.\n\nThis class makes no assumption about the encoding of transferred data and does all its communication as `Uint8List` objects (bytes). Therefore, the terminator can also be specified in bytes. Many network protocols that transmit binary data use specific byte combinations for their terminator strings.\n\nFinally, the terminator may be `null`. In the case of a `null` terminator, all data received over the socket will be piped directly to the data stream.\n\n## Getting started\n\n```bash\ndart pub add tcp_client\n```\n\nIf using Flutter:\n\n```bash\nflutter pub add tcp_client\n```\n\n## Usage\n\n```dart\nimport 'package:tcp_client/tcp_client.dart';\n\n// turn on debug mode\nTcpClient.debug = false;\nvar client = await TcpClient.connect('google.com', 80, terminatorString: '\\r\\n\\r\\n');\n\n// this will watch the connection status\nclient.connectionStream.listen(print);\n\n// this will print out all the received data directly\n// client.dataStream.listen(print);\n\n// this will transform all received data into strings\nclient.stringStream.listen(print);\n\n// res will complete with only the first message as delimited by the terminator\n// in this case (an HTTP request) that will be the headers only\nvar res = await client.sendAndWait('''GET / HTTP/1.1\\r\nHost: google.com\\r\nUser-Agent: curl/7.64.1\\r\nKeep-Alive: false\\r\nAccept: */*''');\n\n// res now has the headers\nprint(res?.body);\n\n// to get the rest of the data (since HTTP doesn't terminate at the end)\nclient.flush();\n\n// clean up\nclient.close();\n\n```\n\n## Additional information\n\nSuggestions and contributions are welcome.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeffmikels%2Ftcp_client_dart","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjeffmikels%2Ftcp_client_dart","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeffmikels%2Ftcp_client_dart/lists"}