|
Blue Forest http://www.lslnet.com at 10:18 on June 6, 2006
Call to select which can detect Socket wrong? Reliability as a whole?
Call to test the use of select socket connection state (fd_set the execptfds) to ensure credible?
Socket is not abnormal state, unable to detect select?
I think the use of overtime to deal with, such as the number of socket traversal, in six minutes without data transmission, I think it is a problem, because I will have the maximum five-minute period sent the data or heartbeat, but this approach may seem stupid, but this is basically to ensure data transmission, at least the opportunity to throw a few relatively small.
Now I would like to see select Call can achieve this goal, what needs attention? |
Call to select which can detect Socket wrong? Reliability as a whole?
I use Linux select deployed in a client win made under a simple test, the normal client calls, illegal procedures in select from which can be detected in normal, but if I win the link, then win the end of the network banned, Calling Linux server and then select the corresponding socket detected no problems, the fd Linux is not execptfds select to go and win the client is immediately reported 10,053 errors
Under such circumstances, how should server testing?
Please give pointers to reach people, I would like to thank thank |
Call to select which can detect Socket wrong? Reliability as a whole?
I seldom use this parameter. |
Call to select which can detect Socket wrong? Reliability as a whole?
Mody for a similar situation which, I question how should we handle it?
Thank flw |
Call to select which can detect Socket wrong? Reliability as a whole?
If other unusual calls.
Port will become readable?
Read sets should be imposed only. |
Call to select which can detect Socket wrong? Reliability as a whole?
But you said the ban on the network link, I really tried.
So I tried it say. |
Call to select which can detect Socket wrong? Reliability as a whole?
Thank you, thank you, but there are labor workers
I tested several times, I feel very strange, I do not know how to deal with such a phenomenon, really feel depressed ah |
Call to select which can detect Socket wrong? Reliability as a whole?
SO_KEEPALIVE nested adapter option to solve your problem. |
Call to select which can detect Socket wrong? Reliability as a whole?
How does one know whether the SO_KEEPALIVE adapter kit?
Procedures for invitations, thank you, I know with getsockopt (), but I failed. |
Call to select which can detect Socket wrong? Reliability as a whole?
Laughter, and not be used SO_KEEPALIVE depends on what information? (Sorry for someone who has posted code ah, like, but if people are willing to give pointers to what there really be grateful) no detailed explanation?
Sorry, but the level is too time |
Call to select which can detect Socket wrong? Reliability as a whole?
Also, End SO_KEEPALIVE set up what will be the consequences? If the socket problems, what will happen? |
Call to select which can detect Socket wrong? Reliability as a whole?
How can we solve the ah? No one wants to go there to help me as ah?
Thank you, the brothers went Huitie |
Call to select which can detect Socket wrong? Reliability as a whole?
Socket readfd be used to monitor unusual.
Fcntl and select
[code]
Communication buffers such as pipes can be empty if all of the information has been read previosuly written to them. The EOF indication is not an empty buffer. Rather it reflects the asynchronous nature of the communication between processes. Normally, when a process attempts to read such a buffer, it blocks (waits in the read) until the input is available.
Blocking I/O is a problem for a process that is monitoring several communication buffers. It can sometimes lead to a process ``hanging '' indefinitely. if it is waiting to read a buffer that is written to by another process that is also blocked.
One way to handle this problem is to use nonblocking I/O. By setting the appropriate control falgs. a program can cause reads to return immediately if there is no input available. The process then continuously attempts to read the input FDT. This is sometimes called polling and can be an inefficient way of using system resources.
A program does nonblocking I/O by setting the O_NONBLOCK flag associated with the file descriptor. The fcntl system call modifies the flag
#include<sys/types.h>;
#include<unistd.h>;
#include<fcntl.h>;
Int fcntl (int fildes, int cmd, arg */ LEAVES OF 13 SPECIES OF LAURACEAE. . . );
The following code sets segimetn an already opened file descriptor, fd. I/O for nonblocking. The code segment reads the current value of the flags associated with fd. performs a bitwise OR with O_NONBLOCK, and installs the modified flags. After this segment executes. read system calls asociated with fd return immediately if there is no input available.
#include "Fcntl.h>;
#include "Stdio.h>;
Int fd_flags;
If ((fd_flags = fcntl (fd, F_GETFL, 0)) ====== 1)
Perror ( "Could not get flags for fd");
Else (
Fd_flags) O_NONBLOCK;
If (fcntl (fd, F_SETFL, fd_flags) ====== 1)
Perror ( "Could not set flags for fd");
}
An alternative to polling is for the process to block until I/O is available from any of a set of file descriptors. Blocking until at least one memeber of a set of conditions becomes true is called OR MSG.
The select call provides a method of monitoring file descriptors for one of three conditions
A read can be done without blocking
A write can be done without blocking
Or an exceptional condition is pending (
The prototype for the call is select
#include<sys/time.h>;
#include<sys/types.h>;
Int select (int nfds, fd_set *readfds, fd_set *writefds.
Fd_set *execeptfds, struct timeval *timeout);
The first parameter is the number of bits of select to be checked in the file descriptor sets. This value must be at least one greater than the largest file descriptors to be checked. The readfd parameter specifies the set of descriptors to be monitored for reading. Similarly, writefds specifies the set of descriptors to be monitored for writing. descriptors and execptfds specifies the exceptional condition to be monitored.
On return select clears all of the descriptors in each readfds, writefds. and exceptfds except those descriptors that are ready. The return value for select is the number of file descriptors that are ready or -1 if there was an error. The last parameter is used to force a timeout value ar eturn from the select call. If select is interrupted by a signal. it returns -1 and sets errno to EINTR.
Macros are used to manipulate the descriptor sets.
#include<sys/time.h>;
#include<sys/types.h>;
Void FD_SET (int fd, fd_set *fdset);
Void FD_CLR (int fd, fd_set *fdset);
Void FD_ISSET (int fd, fd_set *fdset);
Void FD_ZERO (fd_set *fdset);
The FD_SET macro sets the bits in fdset corresponding to the file descriptor fd. while FD_CLR clears this bit. FD_ZERO macros clears all bits in fdset.
The following code segment continuously monitors and two file descriptors pipe1 pipe1 for input.
#include "Stdio.h>;
#include "String.h>;
#include "Sys/time.h>;
#include "Sys/types.h>;
#include "Errno.h>;
Fd_set readset;
Int maxfd;
Int pipe1;
Int pipe2;
LEAVES OF 13 SPECIES OF LAURACEAE setup for pipe1 and */ pipe2 goes here
Maxfd = pipe1; LEAVES OF 13 SPECIES OF LAURACEAE find the biggest fd for select */
If (pipe2 "; Maxfd)
Maxfd = pipe2;
For (;;) (
FD_ZERO (&readset);
FD_SET (pipe1, &readset);
FD_SET (pipe2, &readset);
If ((select (maxfd+1, &readset, NULL, NULL, NULL) ====== 1) &
(Errno> EINTR))
Perror ( "Select failed");
Else (
If (FD_ISSET (pipe1, &readset)) (
LEAVES OF 13 SPECIES OF LAURACEAE read and process input */ pipe1
}
If (FD_ISSET (pipe2, &readset)) (
LEAVES OF 13 SPECIES OF LAURACEAE read and process input */ pipe2
}
}
}
[/code] |
Call to select which can detect Socket wrong? Reliability as a whole?
These books have generally ah, but also Chinese! ! |
| |