还魂僵尸 发表于 2011-01-13 09:04

接着6楼的问题。
既然只读取的操作不能发现连接的断开,为什么不增加一个发送操作?是的,这个想法很好, ...
duanjigang 发表于 2011-01-02 11:56 http://bbs.chinaunix.net/images/common/back.gif


    这个说白了就是一个心跳检测?如果用TCP,个人比较倾向于用TCP本身的心跳,这样,服务器和客户端可以分别自己选择是否处理心跳,交给传输协议自己处理吧……

一介村夫 发表于 2011-01-13 10:46

这个说白了就是一个心跳检测?如果用TCP,个人比较倾向于用TCP本身的心跳,这样,服务器和客户端 ...
还魂僵尸 发表于 2011-01-13 09:04 http://bbs.chinaunix.net/images/common/back.gif


    这个心跳太弱了,拔网线之类的没法检测。

duanjigang 发表于 2011-01-13 11:29

还有人对ICE这个中间件使用过的没?说说使用感受和自己的做法。
这个话题已经收集了不少意见和看法,过几天筹划下,发起一个通讯类中间件实践的项目,欢迎大家踊跃参与喔
也可以就这个中间件的功能和自己的设计方法发表意见。

wheniwasyoung 发表于 2011-01-14 09:20

回复duanjigang


是的,没错。

通讯层就是类似于数据中间件,负责client与业务处理层面的数据接 ...
jiang1013nan 发表于 2011-01-11 15:21 http://bbs.chinaunix.net/images/common/back.gif


    为什么UDP就不太可行呢,我觉得UDP一样,同样通讯层跟业务层分开,对于大数据,可以接收后组包

贺兰云天 发表于 2011-01-14 10:08

为什么UDP就不太可行呢,我觉得UDP一样,同样通讯层跟业务层分开,对于大数据,可以接收后组包
wheniwasyoung 发表于 2011-01-14 09:20 http://bbs.chinaunix.net/images/common/back.gif


    恩,可以的,UDP自己再分包?组包?么非又要用UDP实现一个可靠的流式传输?:wink:

wucailiuxing 发表于 2011-01-14 11:04

UDP传输进行分包的方式 有两种情况是必须要考虑的 一种就是接收的包顺序错乱,这种情况还是比较好处理的 第二种情况就是包丢失 这个情况处理起来比较复杂

wheniwasyoung 发表于 2011-01-14 16:58

UDP传输进行分包的方式 有两种情况是必须要考虑的 一种就是接收的包顺序错乱,这种情况还是比较好处理的 第 ...
wucailiuxing 发表于 2011-01-14 11:04 http://bbs.chinaunix.net/images/common/back.gif


   要实现重发机制

yan8790511 发表于 2011-01-15 01:27

mark,坐看高手论道

gawk 发表于 2011-01-15 14:16

第二种双线程的方式已经是一种不错的模型了,在实际中应用也不少,上面量段文字和图片说明了服务端和客户端 ...
duanjigang 发表于 2011-01-02 11:39 http://bbs.chinaunix.net/images/common/back.gif
man recv
Ifno messages are available at the socket, the receive calls wait for
       a message to arrive, unless the socket is nonblocking(seefcntl(2)),
       inwhich case the value -1 is returned and the external variable errno
       is set to EAGAIN or EWOULDBLOCK.The receive calls normally return any
       dataavailable,uptothe requested amount, rather than waiting for
       receipt of the full amount requested.


RETURN VALUE
       These calls return the number of bytes received,or-1ifanerror
       occurred.   Thereturnvalue will be 0 when the peer has performed an
       orderly shutdown.

ERRORS
       These are some standard errors generated by thesocketlayer.   Addi鈥
       tionalerrors may be generated and returned from the underlying proto鈥
       col modules; see their manual pages.

       EAGAIN or EWOULDBLOCK
            The socket is marked nonblocking and the receive operation would
            block, or a receive timeout had been set and the timeout expired
            before data was received.POSIX.1-2001 allows eithererrorto
            bereturned for this case, and does not require these constants
            to have the same value, so a portable applicationshouldcheck
            for both possibilities.

shtr 发表于 2011-01-23 02:36

我不赞成楼上各位所说的用进程取代线程以防止异常终止的情况,可能是我代码写的少,不明白为什么会发生异常终止。且不说这个,个人觉得好的架构应该是平台无关的,在Windows平台,如何实现fork?CreateProcess?另外,个人喜欢LF线程池模型,简单,稳定。:lol:
页: 1 2 3 4 5 6 [7] 8 9 10 11
查看完整版本: 谈谈你接触的通讯程序的模型