分类: LINUX
2009-07-31 17:05:03
目前各平台通用的设置套接字()连接超时的办法是:
|
xiaosuo@gentux perl $ ./a.out 10.16.101.1 90 1180289276 timeout 1180289279 xiaosuo@gentux perl $ ./a.out 10.16.101.1 90 1 1180289281 timeout 1180289282 |
|
559 timeo = sock_sndtimeo(sk, flags & O_NONBLOCK); 560 561 if ((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV)) { 562 /* Error code is set above */ 563 if (!timeo || !inet_wait_for_connect(sk, timeo)) 564 goto out; 565 566 err = sock_intr_errno(timeo); 567 if (signal_pending(current)) 568 goto out; 569 } |
|
xiaosuo@gentux perl $ ./a.out 10.16.101.1 90 1180290583 timeout 1180290586 xiaosuo@gentux perl $ ./a.out 10.16.101.1 90 2 1180290590 timeout 1180290592 |
和设想完全一致!