Can the file descriptor can be 0?

xiaoxiao2021-03-06  46

People who first contact Unix will get this information in the textbook: Document Descriptors 0, 1 and 2 represent stdin, stdout, and stderr, respectively. So, in our own procedure, it often avoids these "standard" descriptors. For the operation of the network, it is generally determined whether the socket descriptor is greater than 0 after connect (or accept) to determine if the network connection is established.

The problem is that it is here.

A SocketServer program, the Accept client connection successfully creates a new thread, regarding the return value of the Accept as the parameter of the thread. In this thread and the client interacts, execute the required operation.

After the client performs the connection operation, it is found that the connection is frequently disconnected by Server, and Best can't solve it.

After debugging, he found that the return value after the ACCEPT was successfully executed, it would be 0.

Surprisingly, but there is no way to modify the problem after the Server-end program is resolved.

Operating system: SunOS 5.8 Compiler: Sunworkspace Pro4.0 CC

转载请注明原文地址:https://www.9cbs.com/read-73371.html

New Post(0)