Getting “Illegal Seek” error after calling accept()

家住魔仙堡 提交于 2020-01-06 02:55:08

问题


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:


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.



来源:https://stackoverflow.com/questions/2866337/getting-illegal-seek-error-after-calling-accept

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!