{"id":31925043,"url":"https://github.com/stringepsilon/fbnetwork","last_synced_at":"2026-02-17T23:01:18.548Z","repository":{"id":45386987,"uuid":"132908652","full_name":"StringEpsilon/fbNetwork","owner":"StringEpsilon","description":"Object-oriented network library written in and for FreeBASIC.","archived":false,"fork":false,"pushed_at":"2020-02-02T10:56:23.000Z","size":30,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-04-09T10:07:17.097Z","etag":null,"topics":["freebasic","network","object-oriented"],"latest_commit_sha":null,"homepage":"","language":"VBA","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/StringEpsilon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-10T14:03:45.000Z","updated_at":"2022-07-13T16:52:34.000Z","dependencies_parsed_at":"2022-09-24T10:45:12.618Z","dependency_job_id":null,"html_url":"https://github.com/StringEpsilon/fbNetwork","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"purl":"pkg:github/StringEpsilon/fbNetwork","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StringEpsilon%2FfbNetwork","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StringEpsilon%2FfbNetwork/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StringEpsilon%2FfbNetwork/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StringEpsilon%2FfbNetwork/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StringEpsilon","download_url":"https://codeload.github.com/StringEpsilon/fbNetwork/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StringEpsilon%2FfbNetwork/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279017364,"owners_count":26086052,"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","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["freebasic","network","object-oriented"],"created_at":"2025-10-14T00:26:42.429Z","updated_at":"2025-10-14T00:26:45.375Z","avatar_url":"https://github.com/StringEpsilon.png","language":"VBA","readme":"# fbNetwork\n\nfbNetwork is a simple, object oriented network library licensed under the MPL 2.0\n\n## Motivation\n\nSince you can't get a pointer to a method of a UDT / class instance, working with callback based\nnetwork libraries can be a bit of a hassle when the rest of your programm is OOP. This library aims to\nfix that pain by implementing the network part itself in a class so the programmer can simply extend it to\nimplement their parsing, event handling and so on on top.\n\nA very simple HTTP client can be found in the examples folder.\n\n## TODO\n\nHigh level:\n\n* [ ] Testing under real conditions\n* [ ] Test the client and server thoroughly on windows\n* [ ] Get some feedback on the API\n* [ ] Get some feedback on the actual network handling, especially the errorhandling\n\nDetail:\n\n* [ ] Make fbNetworkClient better aware of it's own connection status\n* [x] Write and expose an isConnected property.\n* [x] Make timeout configurable.\n* [x] Figure out a way to close the server properly and end it's thread.\n* [ ] Call handlers for client related events on server in thread.\n\n## extending fbNetworkClient\n\nfbNetworkClient (name might change) is the class you extend for writing your own network client.\n\nYour class can to implement the following subs  as needed. \nOnly onMessage must be implemented, as it it abstract in the base class.\n\n```sub onConnect()```\n\nGets called when the connection is established.\n\n```sub onClose()```\n\nGets called when a connection closes.\n\n```sub onError(errorCode as fbNetworkError = net_undefined)```\n\nGets called when an error occurs on the network. See the fbNetworkError enum for details.\n\n```sub onMessage(message as string)```\n\nGets called when a message / data is received from the server. \n\n## fbNetworkClient API\n\nThe following belong to the public API of the baseclass and thus your client:\n\n```function open(address as string, port as uinteger, timeout as integer, protocol as TransportProtocol = TCP) as boolean```\n\nConnect to the given address and port. \n\nReturns false if connection could not be established. \nReturns true **after** the connection was disconnected regularly. That might take a while ;-)\n\n```sub close()```\n\nClose the connection of the client, if there currently is a connection.\n\n```function sendData(byref _data as string) as boolean```\n\nSends data to the server. Returns true if sending was successful.\n\n## extending fbServer\n\nYour class can to implement the following subs  as needed. Some of these might change from virtual to abstract later.\n\nAlso: I might later change how server implementations are supposed to handle clients. I don't like socket parameter.\n\n```sub onEstablish()```\n\nGets called when the server is ready to listen for incomming connections.\n\n```sub onConnection(client as socket)```\n\nGets called when a client connects, with the socket for that client as a parameter.\n\n```sub onDisconnect(client as socket)```\n\nGets called when a client disconnects.\n\nNote: The socket will immediately be closed after onDisconnect is called.\n\n```sub onMessage(client as socket, message as string)```\nGets called when a client sent data.\n\n```sub onClose()```\nCalled when the server closed and exited it's main eventloop. You can savely restart the server after this was called.\n\n```sub onError()```\nCurrently unused and will probably get a parameter or two later.\n\n## fbServer API\n\nThe following belong to the public API of the baseclass and thus your client:\n\n```function open(port as uinteger, maxConnections as integer = 100, protocol as TransportProtocol = TCP) as boolean```\n\nStarts the server with the given port, connection pool size and protocol. \n\nThis also creates a thread interally you can await with ```waitForShutdown```.\n\n```sub close()```\n\nCloses the server. It can take up to a second for the internal thread to clear after you called this.\n\n```sub waitForShutdown()```\n\nWaits for the internal thread of the server to finish. \n\n\n```function sendData(client as socket, _data as string) as boolean```\n\nSends data to the specified client socket. Returns true if sending was successful.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstringepsilon%2Ffbnetwork","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstringepsilon%2Ffbnetwork","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstringepsilon%2Ffbnetwork/lists"}