FreeSWITCH - mod_xml_rpc源码分析一socket_win.c


TChannel和TChanSwitch结构体

此文件内的函数基本上分成两类。一类的输入参数中包含TChannel结构体变量,另一类的输入参数中包含另一个结构体变量TChanSwitch。初看后觉得二者的差别很小,细看后发现差异在vtbl属性。vtbl这个结构体属性有很多函数指针属性。类似于监听函数(listen)、接受函数(accept)、读函数(read)和写函数(write)等等。TChannel包含读写等函数指针。TChanSwitch包含监听和接受函数指针。因此可以断定TChannel是用来代表一个连接上服务端的socket连接,TChanSwitch用来代表一个服务端socket。即,本文档内的函数分成两类:操作连接上服务端socket的函数,和操作服务端socket的函数。

struct TChannelVtbl {
    ChannelDestroyImpl            * destroy;
    ChannelWriteImpl              * write;
    ChannelReadImpl               * read;
    ChannelWaitImpl               * wait;
    ChannelInterruptImpl          * interrupt;
    ChannelFormatPeerInfoImpl     * formatPeerInfo;
};

struct _TChannel {
    uint                signature;
        /* With both background and foreground use of sockets, and
           background being both fork and pthread, it is very easy to
           screw up socket lifetime and try to destroy twice.  We use
           this signature to help catch such bugs.
        */
    void *              implP;
    struct TChannelVtbl vtbl;
};


struct TChanSwitchVtbl {
    SwitchDestroyImpl   * destroy;
    SwitchListenImpl    * listen;
    SwitchAcceptImpl    * accept;
    SwitchInterruptImpl * interrupt;
};

struct _TChanSwitch {
    uint                   signature;
        /* With both background and foreground use of switches, and
           background being both fork and pthread, it is very easy to
           screw up switch lifetime and try to destroy twice.  We use
           this signature to help catch such bugs.
        */
    void *                 implP;
    struct TChanSwitchVtbl vtbl;
};

TChannel

channelVtbl是个静态变量,保存了本文档内所有操作TChannel结构体的函数指针。

static struct TChannelVtbl const ch
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值