I am using one non blocking socket to send message to the servers.I am using Solaris OS .I am using default buffer size for the socket.The message I am sending roughly size is 20 bytes.I am sending such 18 messages.But I am getting EAGAIN error very occasionally while sending those messages .I observed when I am rebooting the system and send those 18 messages I am getting that EGAIN error .But if Again I am sending those messages afterwards its not giving me any error .Is there any specific reason why its happening after re-boot.
Moreover I want to know when its giving EGAIN its there any way to know how much send buffer is occupied.I dnt have acess to the code of server.So can it be problem of receiving buffer?
You have to delay the send with a timer in a loop, say retry 10 times, then throw a fatal error or just log an error and go on to the next send();
struct timespec tsp={0, 200}; // note you may well sleep longer than the interval....
int rc=0;
int i=0;
fprintf(stderr, "%s: OSS port blocking a send\n", now());
for(i=0; i< 10; i++)
{
nanosleep(&tsp, NULL);
if( (rc=send(s, p, len, 0)>0) )
{
fprintf(stdout, "%s: OSS port send completed\n");
break;
}
}
i think it's not related buffer size..this is probably read (like uncompleted read) on socket problem for some reasons (slow network or high load )..
for this in your code you can set timeout (probably already ) or increase a bit
..........
struct timeval {
int wait_time.tv_sec;
int wait_time.tv_usec;
};
............
wait_time.tv_sec = 30; /* "wait_time.tv_sec = 1 * 60; " change try to one minute */
wait_time.tv_usec = 0;
.....
select(max_descriptor+1, &read_flags,&write_flags,(fd_set*)0,&wait_time);
......
Thanks for your Reply.I am getting max buffer size for sending as 65525.Which is not so less I guess.
We are sending 12 messages of size 20Bytes .And we are doing it localserver only.
---------- Post updated 10-27-10 at 01:49 AM ---------- Previous update was 10-26-10 at 05:32 AM ----------
Hi
I am trying use flush(socket) to clean up the buffer.But flush is blocking the blow .its stuck there only.Any reason that flush is not supported in Non blocking call .Please Clarify