RSS Feed

Posts Tagged ‘网络’

  1. boost::asio::async_read 的一些记录

    十二月 30, 2009 by bborn

    boost中的asio是一个非常好用的网络库
    不过可以参考的资料比较少
    大部分都是靠阅读自带的几个example来理解
    这里记录一下这两天的几个心得

    boost::asio::async_read_until(socket_, response_, “\r\n\r\n”, boost::bind(&shoutcast::handle_read_headers, this, boost::asio::placeholders::error));

    async_read_until, 一直读,直到读到指定的内容.但是了,并不是刚刚读到就停止,一般缓冲区里会有更多的内容,
    所以我们需要读出我们需要的,剩下的留下就好
    官方是这么说的”After a successful async_read_until operation, the streambuf may contain additional data beyond the delimiter. An application will typically leave that data in the streambuf for a subsequent async_read_until operation to examine.”

    boost::asio::async_read(socket_, response_, boost::asio::transfer_at_least(512), boost::bind(&shoutcast::handle_read_content, this, boost::asio::placeholders::error));

    async_read 可以选择使用transfer_at_least 这个CompletionCondition
    async_read 读入的缓冲区可以这样
    boost::array buffer_;
    boost::asio::buffer(buffer_);来构造
    也可以直接用字符数组来构造
    char _buf[512] = {0};
    boost::asio::buffer(_buf, 512);
    也可以用流,更像tcp的方式
    使用boost::asio::streambuf response_;
    它继承自 std::streambuf
    一般这样使用
    std::istream _stream(&response_);
    这里要注意的是 basic_istream::get
    如果我们指定get的个数count,那么取出的个数是count-1
    msdn是这样说的”The fourth function extracts up to _Count – 1 elements and stores them in the array beginning at _Str.”


  2. 终于可以上网了

    九月 8, 2005 by bborn

    昨天申请了账号
    但是怎么设置都不行
    今天同学打了个电话过去
    是网管那边没有搞好
    哈哈
    中午小试了一下bt
    下天下足球有500k左右的速度
    网速是要快些阿


  3. opera 十年

    八月 31, 2005 by bborn


    opera 浏览器现在正在提供免费注册

    记得opera 这个单词
    我还真的是从这个浏览器学到的
    那个时候他号称世界上最快的浏览器
    事实我想确实如此
    踩着小猫步
    都能体验到那种滚动条迅速缩短的感觉

    手机上的opera同样不错
    移动版的我只用过symbian的
    可惜他不提供免费注册[cry]