这是我吹牛的地方

想怎么吹就怎么吹

知道什么叫同步和异步吗?

In synchronous receiving, while the server is waiting to receive data from a client, if the stream is empty the main thread will block until the request for data is satisfied. Hence, the server cannot do anything else until it receives data from the client. If another client attempts to connect to the server at that time, the server cannot process that request because it is blocked on the first client. This behavior is not acceptable for a real-world application where we need to support multiple clients at the same time.

In asynchronous communication, while the server is listening or receiving data from a client, it can still process connection requests from other clients as well as receive data from those clients. When a server is receiving asynchronously, a separate thread (at the OS level) listens on the socket and will invoke a callback function (specified when the asynchronous listening was commenced) when a socket event occurs. This callback function in turn will respond and process that socket event. For example, if the remote program writes some data to the socket, a "read data event" (callback function you specify) is invoked; it knows how to read the data from the socket at that point.

简而言之,同步是一对一的,异步是一对多的。我翻译的太牛了,这么多英文就让我一句话就概括了。

posted on 2006-09-19 14:42 西门吹牛 阅读(3041) 评论(7)  编辑  收藏

评论

# re: 知道什么叫同步和异步吗? 2006-11-06 15:34 chicken

你翻译的很垃圾阿 看了英文才懂。。。  回复  更多评论   

# re: 知道什么叫同步和异步吗? 2006-12-01 14:50 心内求法

好像不是翻译的问题,是理解的问题,呵呵  回复  更多评论   

# re: 知道什么叫同步和异步吗? 2008-07-18 12:50 dog

就是一夫多妻和一夫一妻  回复  更多评论   

# re: 知道什么叫同步和异步吗? 2009-04-21 14:10 恩 恩! 真是吹牛的好地方

...  回复  更多评论   

# re: 知道什么叫同步和异步吗?[未登录] 2009-06-11 17:10 无名

概括得好,顶!!!!再顶!!!!  回复  更多评论   

# re: 知道什么叫同步和异步吗? 2009-07-12 01:21 卡人力窝里反

英文单词的原意和中文的翻译之间,差别很大,甚至是南辕北辙的!  回复  更多评论   

# re: 知道什么叫同步和异步吗? 2009-07-30 14:52 北京的太阳

在同步接收方式下,当服务器等待从客户端的数据时,如果传输流是空的,主线程会进入阻塞状态,直到(向客户端的)数据请求被满足。因此,服务器不能做其他的操作,直到接收到客户端的数据。如果同时有另外一个客户端试图连接服务器,服务器不能够处理请求,因为主线程被第一个客户端设置为阻塞。这种(同步)方式对于需要在同一时间支持多客户端的实际应用(程序)是不能够被接受的。
在异步通信方式下,当服务器监听或者接受一个客户端的数据时,它能够同时连接其他的客户端并且从其他的客户端接收数据。当服务器异步地接收(数据),一个单独的现成(操作系统级别)监听socket并且当发生socket事件时,会调用一个响应函数(指定异步监听什么时候开始)。响应函数会轮流地响应和处理socket事件。例如:如果远程程序向一个socket写一些数据,一个“写数据事件”(你指定的响应函数)被调用,在那一时刻它(函数)知道如何从socket读数据。  回复  更多评论   


只有注册用户登录后才能发表评论。


网站导航:
 
<2006年9月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

导航

统计

常用链接

留言簿(5)

随笔档案

文章档案

相册

搜索

最新评论

阅读排行榜

评论排行榜