📄 16.htm
字号:
<HTML><HEAD><TITLE>CTerm非常精华下载</TITLE>
<META content="text/html; charset=gb2312" http-equiv=Content-Type></HEAD>
<BODY bgColor=#ffffff>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=100% background=0044.jpg>
<BODY>
<TR>
<TD height=150 rowSpan=2 width="308" ><IMG alt=DDl_back.jpg height=129 width=300 src="DDl_back.jpg" ></TD>
<TD background=DDl_back2.jpg height=50 width="581" ><BIG><BIG><FONT face=黑体>
<P align=center >重拳出击 一网打尽</FONT></BIG></BIG></P></TD></TR>
<TR>
<TD bgColor=#0099ff borderColor=#0099ff height=5 width="581"></TD></TR>
<TR>
<TD align=middle colSpan=2 height=100 vAlign=top width="891" ><BR>
<p align=center>[<a href="清华bbs网络资源.htm">回到开始</a>][<a href="3.htm">上一层</a>][<a href="17.htm">下一篇</a>]
<hr><p align="left"><small>发信人: gorilla (再大的猩猩我们都见过), 信区: Winsock <br>
标 题: 如何使用非阻塞模式 <br>
发信站: BBS 水木清华站 (Thu Oct 29 09:43:54 1998) <br>
<br>
本人想开发一个非阻塞模式的客户端的connect() <br>
但是不知道如何能做到,请各位大侠指点 <br>
<br>
-- <br>
※ 来源:·BBS 水木清华站 bbs.net.tsinghua.edu.cn·[FROM: 202.112.101.44] <br>
发信人: zixia (没有美眉〓大木瓜), 信区: Winsock <br>
标 题: Re: 如何使用非阻塞模式 <br>
发信站: BBS 水木清华站 (Thu Oct 29 16:16:03 1998) <br>
<br>
<br>
我想要阻塞模式的! <br>
<br>
呵呵,不过是服务器端的组塞模式的。 <br>
<br>
非组塞的 socket 可以看看 WSAsyncSelect() 函数的帮助。 <br>
<br>
【 在 gorilla (再大的猩猩我们都见过) 的大作中提到: 】 <br>
: 本人想开发一个非阻塞模式的客户端的connect() <br>
: 但是不知道如何能做到,请各位大侠指点 <br>
<br>
<br>
-- <br>
爱情来得快去得也快,只有猪肉卷是永恒的. <br>
<br>
紫虾大餐:zixia.yeah.net <br>
<br>
My E-mail:zixia@126.com <br>
嘻嘻,比特仙子这里有礼了^_^没空儿~~~~~~~~~~~讨论爱情~~~ <br>
<br>
※ 来源:·BBS 水木清华站 bbs.net.tsinghua.edu.cn·[FROM: 166.111.49.42] <br>
发信人: numerical (compiler), 信区: Winsock <br>
标 题: Re: 如何使用非阻塞模式 <br>
发信站: BBS 水木清华站 (Fri Oct 30 00:53:26 1998) <br>
<br>
【 在 gorilla (再大的猩猩我们都见过) 的大作中提到: 】 <br>
: 本人想开发一个非阻塞模式的客户端的connect() <br>
: 但是不知道如何能做到,请各位大侠指点 <br>
<br>
First I shall say I have no idea about winsock, and <br>
only have a little experience in BSD socket. <br>
But I think the underlying idea may be the same. <br>
<br>
In the FreeBsd code, there are a lot of stuff <br>
for implementing the TCP protocol, including the <br>
connect function implemntation. <br>
One thing we notice is that it is NOT error <br>
when connect() return EINPROGRESS errno, when we want <br>
non-blocking connect(). So, we should check <br>
this condition in our code. <br>
<br>
After the above condition , we can say that the connection <br>
is established. Then we use select function to <br>
select which channal we ca use now(such as socket, stdin). <br>
[Hee I assume that you know how to use fcntl-select function <br>
pairs to handle non-blocking model] <br>
<br>
Also, we may close non-blocking at the end of the code. <br>
<br>
The simpele psdudo-code is are as follows: <br>
<br>
// fcntl to set non-blocking <br>
<br>
<br>
<br>
// connect checking to see EINPROGRESS errno <br>
<br>
// select chanalls <br>
<br>
/* <br>
* some work here <br>
*/ <br>
<br>
// close the socket in some situation <br>
<br>
The difficulty in implementing non-blocking connect() <br>
is portabliity problem, which means that it depends <br>
on your socket implementation(winsocket, or unix socket,etc.) <br>
So I hope the above idea is useful for you and suggest <br>
you understand the implemenation of your socket. <br>
<br>
By the way, someone suggested to use a thread to do it. <br>
But I haven't tired. <br>
<br>
-- <br>
※ 来源:·BBS 水木清华站 bbs.net.tsinghua.edu.cn·[FROM: 210.32.145.3] <br>
发信人: kee (罐罐), 信区: Winsock <br>
标 题: Re: 如何使用非阻塞模式 <br>
发信站: BBS 水木清华站 (Tue Nov 3 18:00:40 1998) WWW-POST <br>
<br>
unix下: <br>
<br>
fcntl(sockfd,F_SETFL,O_NDELAY); <br>
-- <br>
<br>
/\.------\_/~ <br>
^_' \ ___ / <br>
W W <br>
<br>
※ 来源:·BBS 水木清华站 bbs.net.tsinghua.edu.cn·[FROM: 202.118.6.141] <br>
</small><hr>
<p align="center">[<a href="清华bbs网络资源.htm">回到开始</a>][<a href="3.htm">上一层</a>][<a href="17.htm">下一篇</a>]<p align="center" ><font face="黑体" size=5><big>网络资源大全</big></font></p>
</table>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -