⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 22.htm

📁 unix高级编程原吗
💻 HTM
字号:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>CTerm非常精华下载</title>
</head>
<body bgcolor="#FFFFFF">
<table border="0" width="100%" cellspacing="0" cellpadding="0" height="577">
<tr><td width="32%" rowspan="3" height="123"><img src="DDl_back.jpg" width="300" height="129" alt="DDl_back.jpg"></td><td width="30%" background="DDl_back2.jpg" height="35"><p align="center"><a href="http://apue.dhs.org"><font face="黑体"><big><big>123</big></big></font></a></td></tr>
<tr>
<td width="68%" background="DDl_back2.jpg" height="44"><big><big><font face="黑体"><p align="center">               ● UNIX网络编程                       (BM: clown)                </font></big></big></td></tr>
<tr>
<td width="68%" height="44" bgcolor="#000000"><font face="黑体"><big><big><p   align="center"></big></big><a href="http://cterm.163.net"><img src="banner.gif" width="400" height="60" alt="banner.gif"border="0"></a></font></td>
</tr>
<tr><td width="100%" colspan="2" height="100" align="center" valign="top"><br><p align="center">[<a href="index.htm">回到开始</a>][<a href="16.htm">上一层</a>][<a href="23.htm">下一篇</a>]
<hr><p align="left"><small>发信人: fion (fion), 信区: UNP <br>

标  题: unix socket faq (1) <br>

发信站: UNIX编程 (2001年07月07日09:36:46 星期六), 站内信件 <br>

  <br>

  <br>

Newsgroups: comp.unix.programmer,comp.unix.answers,comp.answers,news.answers <br>

From: vic@brutus.tlug.org (Vic Metcalfe) <br>

Subject: [comp.unix.programmer] Unix-socket-faq for network programming <br>

Followup-To: comp.unix.programmer <br>

X-Newsreader: TIN [version 1.2 PL2] <br>

Organization: Zymurgy Systems, Aurora, Ontario, Canada <br>

Message-ID: <1998Mar22.123227.1526@brutus.tlug.org> <br>

Date: Sun, 22 Mar 1998 12:32:27 GMT <br>

Summary: This posting offers answers to frequent questions about network <br>

         programming in the unix environment using sockets. <br>

Archive-name: unix-faq/socket <br>

Posting-Frequency: monthly <br>

Last-modified: 1998/01/22 <br>

URL: http://www.ibrado.com/sock-faq/ <br>

  Programming UNIX Sockets in C - Frequently Asked Questions <br>

  Created by Vic Metcalfe, Andrew Gierth and other con- <br>

  tributers <br>

  January 22, 1998 <br>



  This is a list of frequently asked questions, with answers about pro- <br>

  gramming TCP/IP applications in unix with the sockets interface. <br>

  ______________________________________________________________________ <br>

  <br>

  Table of Contents: <br>

  1.      General Information and Concepts <br>

  1.1.    About this FAQ <br>

  1.2.    Who is this FAQ for? <br>

  1.3.    What are Sockets? <br>

  1.4.    How do Sockets Work? <br>

  1.5.    Where can I get source code for the book [book title]? <br>

  1.6.    Where can I get more information? <br>

  <br>

  2.      Questions regarding both Clients and Servers (TCP/SOCK_STREAM) <br>

  2.1.    How can I tell when a socket is closed on the other end? <br>

  2.2.    What's with the second parameter in bind()? <br>

  2.3.    How do I get the port number for a given service? <br>

  2.4.    If bind() fails, what should I do with the socket descriptor? <br>

  2.5.    How do I properly close a socket? <br>

  2.6.    When should I use shutdown()? <br>

  2.7.    Please explain the TIME_WAIT state. <br>

  2.8.    Why does it take so long to detect that the peer died? <br>



  2.9.    What are the pros/cons of select(), non-blocking I/O and <br>

          SIGIO? <br>

  2.10.   Why do I get EPROTO from read()? <br>

  2.11.   How can I force a socket to send the data in its buffer? <br>

  2.12.   Where can a get a library for programming sockets? <br>

  2.13.   How come select says there is data, but read returns zero? <br>

  2.14.   Whats the difference between select() and poll()? <br>

  2.15.   How do I send [this] over a socket? <br>

  2.16.   How do I use TCP_NODELAY? <br>

  2.17.   What exactly does the Nagle algorithm do? <br>

  2.18.   What is the difference between read() and recv()? <br>

  2.19.   I see that send()/write() can generate SIGPIPE. Is there any <br>

          advantage to handling the signal, rather than just ignoring <br>

          it and checking for the EPIPE error? Are there any useful <br>

          parameters passed to the signal catching function? <br>

  2.20.   After the chroot(), calls to socket() are failing.  Why? <br>

  2.21.   Why do I keep getting EINTR from the socket calls? <br>

  2.22.   When will my application receive SIGPIPE? <br>

  2.23.   What are socket exceptions?  What is out-of-band data? <br>

  2.24.   How can I find the full hostname (FQDN) of the system I'm <br>

          running on? <br>

  <br>

  <br>

  3.      Writing Client Applications (TCP/SOCK_STREAM) <br>

  3.1.    How do I convert a string into an internet address? <br>

  3.2.    How can my client work through a firewall/proxy server? <br>

  3.3.    Why does connect() succeed even before my server did an <br>

          accept()? <br>

  3.4.    Why do I sometimes lose a server's address when using more <br>

          than one server? <br>

  3.5.    How can I set the timeout for the connect() system call? <br>

  3.6.    Should I bind() a port number in my client program, or let the <br>

          system choose one for me on the connect() call? <br>

  3.7.    Why do I get "connection refused" when the server isn't <br>

          running? <br>

  3.8.    What does one do when one does not know how much information <br>

          is comming over the socket ? Is there a way to have a dynamic buffer ? <br>

  <br>

  4.      Writing Server Applications (TCP/SOCK_STREAM) <br>

  4.1.    How come I get "address already in use" from bind()? <br>

  4.2.    Why don't my sockets close? <br>

  4.3.    How can I make my server a daemon? <br>

  4.4.    How can I listen on more than one port at a time? <br>

  4.5.    What exactly does SO_REUSEADDR do? <br>

  4.6.    What exactly does SO_LINGER do? <br>



  4.7.    What exactly does SO_KEEPALIVE do? <br>

  4.8.    How can I bind() to a port number < 1024? <br>

  4.9.    How do I get my server to find out the client's address / <br>

          hostname? <br>

  4.10.   How should I choose a port number for my server? <br>

  4.11.   What is the difference between SO_REUSEADDR and SO_REUSEPORT? <br>

  4.12.   How can I write a multi-homed server? <br>

  4.13.   How can I read only one character at a time? <br>

  4.14.   I'm trying to exec() a program from my server, and attach my <br>

          socket's IO to it, but I'm not getting all the data across.  Why? <br>

  <br>

  5.      Writing UDP/SOCK_DGRAM applications <br>

  5.1.    When should I use UDP instead of TCP? <br>

  5.2.    What is the difference between "connected" and "unconnected" <br>

          sockets? <br>

  5.3.    Does doing a connect() call affect the receive behaviour of <br>

          the socket? <br>

  5.4.    How can I read ICMP errors from "connected" UDP sockets? <br>

  5.5.    How can I be sure that a UDP message is received? <br>

  5.6.    How can I be sure that UDP messages are received in order? <br>

  5.7.    How often should I re-transmit un-acknowleged messages? <br>

  5.8.    How come only the first part of my datagram is getting <br>



          through? <br>

  5.9.    Why does the socket's buffer fill up sooner than expected? <br>

  <br>

  6.      Advanced Socket Programming <br>

  6.1.    How would I put my socket in non-blocking mode? <br>

  6.2.    How can I put a timeout on connect()? <br>

  <br>

  7.      Sample Source Code <br>

  ______________________________________________________________________ <br>

-- <br>

※ 来源:·UNIX编程 www.tiaozhan.com/unixbbs/·[FROM: 211.69.197.132] <br>

</small><hr>
<p align="center">[<a href="index.htm">回到开始</a>][<a href="16.htm">上一层</a>][<a href="23.htm">下一篇</a>]
<p align="center"><a href="http://cterm.163.net">欢迎访问Cterm主页</a></p>
</table>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -