It's still very early, but the basic client works now. And I really need people to test it and give me some feedback on how it feels to use it.
* TCP and UDP
* Windows and Linux
* IPv4 and IPv6
fbNetwork on GitHub - MPL 2.0 as usual.
Motivation (from the readme)
Since you can't get a pointer to a method of a UDT / class instance, working with callback based network libraries can be a bit of a hassle when the rest of your programm is OOP. This library aims to fix that pain by implementing the network part itself in a class so the programmer can simply extend it to implement their parsing, event handling and so on on top.
A very simple HTTP client can be found in the examples folder.
Code: Select all
#include once "../src/fbNetworkClient.bas"
const NEWLINE = !"\r\n"
type httpClient extends fbNetworkClient
declare sub onConnect()
declare sub onClose()
declare sub onError(errorCode as fbNetworkError)
declare sub onMessage(message as string)
dim request as string
"GET / " + "HTTP/1.1" + NEWLINE + "Host: httpstat.us " + NEWLINE + _
"Connection: close" + NEWLINE + "User-Agent: GetHTTP 0.0" + NEWLINE + NEWLINE )
print "Connected to "& this.host & ":" & this.port
sub httpClient.onError(errorCode as fbNetworkError)
sub httpClient.onMessage(message as string)
print "Got data: ";
print trim(right(message, len(message) - instrRev(message, NEWLINE)-1),any NEWLINE)
dim client as httpClient
print "Testing ipv4.icanhazip.com"
If you got any feedback, bugs or patches, I'd really appreciate it. But keep in mind that I might not be fast to respond to windows specific bugs.
Ideas for sane error handling are also very welcome.