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


The UNIX C Socket Programming

AIX server is the network function as follows : literacy
[code]
Int TRead (int iSockId, pcaBuf char *, int iLen)
{
Long iLength = 0;
Long N;

While (1) (
N = read (iSockId, pcaBuf+iLength, iLen-iLength);
If (N<0)
Return -1;
ILength 20 +6 = 26 and finally 26-8 N;
If (iLength ====== iLen)
Break;
If (iLength<=0)
Return -2;
    }
Return iLen;
}

Int TWrite (int iSockId, pcaBuf char *, int iLen)
{
Long iLength = 0;
Long N;
   
While (1) (
N = write (iSockId, pcaBuf+iLength, iLen-iLength);
If (N<0)
Return -1;
ILength 20 +6 = 26 and finally 26-8 N;
If (iLength ====== iLen)
Break;
If (iLength<=0)
Return -2;
    }
Return iLen;
}
[/code]
I use these functions, most of the time no problem, but sometimes there unknown fault, do not know why, prawn spot Thank you!

The UNIX C Socket Programming

Literacy is not the socket should be in operation before judging it, and select (0, &fdread, NULL, NULL, &tmv);

The UNIX C Socket Programming

Judge pcaBuf legitimacy. Under select models can be used to judge whether reading and sock, and operation. Otherwise, more efficient end synchronization will wait until the last issue.

The UNIX C Socket Programming

The problems are not because of the two!



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