Linux -Blue forest free software | Return to home page | Site Map | Search WWW | Contact Us |
Your current position : Homepage > Free Software > Technological exchanges >Application Programming


    

Blue Forest http://www.lslnet.com at 10:18 on June 6, 2006


Socket, software testing group back to my original code, Jia, Online!

Socket sent the data used in the process, from how to set up overtime?

Now I have come across the problem of data transmission socket in the process, get rid of lines on the transmission process stopped, the entire process will be blocked, (Note : I have installed into a socket nonblocking and if from the other side of the socket, it can be returned, but now it is directly promote lines).

Software testing of the test when the group returned to my original code.

Please help to the solution months, the National Day will be wasted.

Frank!

Socket, software testing group back to my original code, Jia, Online!

Use select

Socket, software testing group back to my original code, Jia, Online!

Linux, on Lane send Thread

Socket, software testing group back to my original code, Jia, Online!

What are the conditions?
Unix send always been successful in general, the lines are extracted trip
The buffer zone is only going to send transmission

Socket, software testing group back to my original code, Jia, Online!

There are three ways to set up socket overtime.

1. Socketfd to be addressed, call select (), and that overtime hours.

2. To handle the socketfd Calling setsockopt (), a choice of setting up overtime.

3. Call alrm first (and Iran), read, or recv connect, accept failure capture, and then determine whether overtime is wrong.

I do not Unix environment, or else some substituting it for you posted.

See also "<unix Network Programming, Vol 1" ;>;, detailed above.

Socket, software testing group back to my original code, Jia, Online!

I use the write and send a distinction?
There is no distinction between the reference.

I came across such a situation, the first socket is normal, and removing obstructions on the lines where the lines have been stabbed Internet or send out the data, but it has lost its socket.

I want to solve the problem is to get rid of lines, so write back to the failure of function, rather than where the obstruction? ?

Socket, software testing group back to my original code, Jia, Online!

Void
#if ANSI_C
SetSocketBuffer (int fd, int bufSize)
#else
SetSocketBuffer (fd, bufSize)
Int int bufSize; fd;
#endif
{
Int bval, blen=sizeof (bval);
LEAVES OF 13 SPECIES OF LAURACEAE set send/recv buffer sizes */
If (getsockopt (fd, SOL_SOCKET, SO_RCVBUF, &bval, &blen) ==0) (
Fprintf (stderr, "recvbuf buf is %d\n" bval);
}
If (getsockopt (fd, SOL_SOCKET, SO_RCVBUF, &bval, &blen) ==0, named bval<bufSize) (
Bval=bufSize;
Fprintf (stderr, "set to %d\n recvbuf buf," bval);
If (setsockopt (fd, SOL_SOCKET, SO_RCVBUF, &bval, blen) ==-1)
{
Perror ( "setsockopt");
Exit (0);
}
}
    }
If (getsockopt (fd, SOL_SOCKET, SO_SNDBUF, &bval, &blen) ==0, named bval<bufSize) (
Bval=bufSize;
If (setsockopt (fd, SOL_SOCKET, SO_SNDBUF, &bval, blen) ==-1)
        {
Perror ( "setsockopt");
Exit (0);
        }
    }
}

BUF set up to determine how much data you to discover network anomalies, depending on different operating systems, different characteristics, pulled out regulation of electricity lines and routing, TCP wrong, it is very difficult to discover.
Read WRITE terminal and the proposed increase ACK end, the definition of overtime, to solve alone.

Socket, software testing group back to my original code, Jia, Online!

Following is an example write
Int
#if ANSI_C
Write (int fd, char *buf, size_t entrants, tout int, int uout)
#else
Write (fd, buf, practically, tout, uout)
Fd; char *buf; size_t len; int int int uout; tout;
#endif
{
Fd_set writeset;
Struct timeval time;
Int ret, wsize, wlen;
Time.tv_sec = tout;
Time.tv_usec = uout;
Wsize=0;
Wlen=len;
For (are;)
{
FD_ZERO (&writeset);
FD_SET (fd, &writeset);
Ret = select (fd+1, NULL, &writeset, NULL, &time);
If (ret "0)
                {
If (errno==EINTR)
Continue;
Return 1;
                }
If (ret ====== 0)
Return wsize;

If (!FD_ISSET (fd, &writeset))
Return 1;
Ret = write (fd, buf+wsize, wlen);
If (ret "0)
                {
If (errno ====== ====== EINTR | | errno EAGAIN)
Continue;
Return 1;
}else{
Wsize 20 +6 = 26 and finally 26-8 ret;
Wlen -= ret;
                }
If (wlen "= 0)
Return len;
        }

}



 Privacy Policy  Copyright © 1999-2000 LSLNET.COM. All rights reserved. Blue Forest website owners. E-mail : Webmaster@lslnet.com