Skip to main content
GameDev.net gamedev.net
🔒 Locked

send() error..

Started by peccavi Nov 2, 2004 at 4:06 AM 2 replies 550+ views
Original Post
peccavi
peccavi
Hello! Now I'm making TCP/IP server with poll on linux. server send a packet to client 20times/1sec while 30 minutes. but sometimes the send() function returns -1. errno are... 9(EBADF) - bad file number 11(EAGAIN) - try again do i retry the send()? or just ignore? please help me.. T T
Lord Bart
Lord Bart
Hello peccavi,

The EAGAIN you should be able to resend, It meeans Allocation of interl data struct fail but request may be attempted agian. (man poll)
The EBADF I think something happen to your opened file descritor(ie socket) and I don't think you would be able to resend.

Hope that helps some.

Also even if send return -1 doesn't mean message didn't go through.

Lord Bart :)
peccavi
peccavi
thank you so much!!
very helpful to me..

but when errno was EAGAIN, my codes are...

do
{
ret = send(...);
if( ret == -1 )
{
if( errno == 9 ) break;
else if( errno == 11 ) continue;
}
}

it runs again and again when errno is 11(EAGAIN)..

how can i modify that code?

T T
hplus0603
hplus0603
Is the other end receiving at all? You could probably get EAGAIN if the buffer is full and the other end isn't draining it.

And, no, there isn't really a great way of re-writing that code (except by using the symbolic names rather than integer values). If you don't like the CPU usage, then use select() to figure out when your socket is writable without wasting CPU.
enum Bool { True, False, FileNotFound };

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.