telnet and D
maarten van damme
maartenvd1994 at gmail.com
Thu Nov 29 06:32:39 PST 2012
> vibe.d is very modular, just import what you need.
> I hate to push it, but it has very good documentation and examples.
>
> Its designed for web apps, but it makes a nice little web library as well.
>
> import vibe.vibe;
>
> void main()
> {
> auto client = new HttpClient;
> client.connect("www.google.com", 80);
>
> auto res = client.request((req){
> req.url = "/";
> });
>
> logInfo("Response: %d", res.statusCode);
>
> foreach( k, v; res.headers )
> logInfo("Header: %s: %s", k, v);
>
> (new NullOutputStream).write(res.bodyReader);
> client.disconnect();
> }
>
>
That does indeed look clean. Now I'm using a ubyte[1] buffer to try
and read single bytes from my sockets.
their tcp example looks pretty clean:
import vibe.d;
static this()
{
auto conn = connectTcp("time-b.timefreq.bldrdoc.gov", 13);
logInfo("The time is: %s", cast(string)conn.readAll());
}
let's see how it'll hold up when I try to deal with raw bytes :)
More information about the Digitalmars-d-learn
mailing list