tags:

views:

62

answers:

1

Well.. it's pretty much that, I seem to be getting a "Illegal Seek" error when checking my errno variable. The problem is that I have no idea of what that can mean.

I know sockets are treated like files in unix, but I can't see how can this be related to sockets. What I'm doing exactly is:

int sck = ::accept(m_socket, (struct sockaddr*)&client_address, (socklen_t*)&address_len);

Then I get sck = -1 and errno = ESPIPE

And the weird thing is that it happens randomly. I mean, sometimes the code works fine, and sometimes it just thows an exception. I'm working with threads so that's understandable. But I just would like to know what kind of behaviour makes the accept() call to set errno as ESPIPE so I could check the paramethers for instance.

Thanks Nelson R. Pérez

+1  A: 

The most probable cause is that the m_socket variable is being corrupted. Use strace as @Aidan suggests to see what value is being passed to accept(2), or attach a debugger to the process and set a watchpoint on that memory location.

Nikolai N Fetissov
Not necessarily the variable - it might be that the file descriptor has been closed and another file was opened and assigned the same number (since they're always assigned sequentially).
R..
Hmm, yes, possible. That would sorta qualify as corruption though :) and a watchpoint would show where it's being changed.
Nikolai N Fetissov