About the command handling of MSN protocol

Peng Jing pj.phantom at yahoo.com.cn
Tue Jun 23 09:53:48 EDT 2009


Thanks for your reply.
Did you mean this:
      we do all the things in a single thread:
      1. Invoke select() or use some similar methods to read the data coming from the socket when there is any.
      2. If we read data successfully, parse the data received(Maybe we need to tokenize the commands and enqueue them).
      3. If there are unhandled commands in the queue, pick one from the head of queue, call the corresponding functions to handle it.
      4. Loop.(goto Step 1 to continue)

Am I right?

----------------------------------------------------

Jing Peng(彭井), BUPT

--- 09年6月23日,周二, Mark Doliner <mark at kingant.net> 写道:

发件人: Mark Doliner <mark at kingant.net>
主题: Re: About the command handling of MSN protocol
收件人: "Peng Jing" <pj.phantom at yahoo.com.cn>
抄送: support at pidgin.im
日期: 2009年6月23日,周二,下午3:04

On Mon, Jun 22, 2009 at 6:17 AM, Peng Jing<pj.phantom at yahoo.com.cn> wrote:
> 2).
> I plan to employ some multi-threading: one thread keeps listenning to the
> incoming commands from the server, put them in a cache, and the other thread
> scans the cache and pick out those complete commands and enqueue them. But
> this may involve some thread synchronization problems which are a little
> difficult and tedious to deal with.
> Does anyone have some good ideas?

One popular technique for network I/O is to watch the network socket
for incoming data, then call read() when you know there is something
to be read.  The poll() and select() functions are the traditional
ways of doing this.  libevent and libev are probably more convenient,
if you want to support multiple-platforms.  Or if you're developing a
glib application you can use GIOChannels.

-Mark



      ___________________________________________________________ 
  好玩贺卡等你发,邮箱贺卡全新上线! 
http://card.mail.cn.yahoo.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://pidgin.im/pipermail/support/attachments/20090623/42507bd5/attachment.html>


More information about the Support mailing list