Unix Programming - Illegal seek in Unix Domain Socket

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > April 2004 > Illegal seek in Unix Domain Socket





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Illegal seek in Unix Domain Socket
Ole Jacob Hagen

2004-04-19, 3:35 pm

Hi.

I am making an application that are interfaced from Octave by Unix
Domain sockets.

I am struggling with an error-message, which appears when I am using
perror-function, after I have read from socket. I am using read-function.

I discovered during compliation perror-function is deprecated, and
should be replaced with strerror. Is it?

If I am using the strerror instead of perror, I get no errors, but when
I use perror, errors might occur.

Any Comments?

Ole J.
Måns Rullgård

2004-04-19, 3:35 pm

Ole Jacob Hagen <waterthrill@yahoo.no> writes:

> Hi.
>
> I am making an application that are interfaced from Octave by Unix
> Domain sockets.
>
> I am struggling with an error-message, which appears when I am using
> perror-function, after I have read from socket. I am using
> read-function.
>
> I discovered during compliation perror-function is deprecated, and
> should be replaced with strerror. Is it?
>
> If I am using the strerror instead of perror, I get no errors, but
> when I use perror, errors might occur.


Any error would have occurred before you call either of those
functions. If whatever function you called prior to perror/strerror
returned an error indication there was an error, otherwise there
probably was none.

You mention "Illegal seek" and sockets in the subject line. This
would indicate that you are trying to do a seek on a socket.
Obviously, this is impossible.

--
Måns Rullgård
mru@kth.se
Fletcher Glenn

2004-04-19, 5:34 pm



Ole Jacob Hagen wrote:
> Hi.
>
> I am making an application that are interfaced from Octave by Unix
> Domain sockets.
>
> I am struggling with an error-message, which appears when I am using
> perror-function, after I have read from socket. I am using read-function.
>
> I discovered during compliation perror-function is deprecated, and
> should be replaced with strerror. Is it?
>
> If I am using the strerror instead of perror, I get no errors, but when
> I use perror, errors might occur.
>
> Any Comments?
>
> Ole J.


perror or strerror will not produce meaningful errors unless read
returns -1. If you are arbitrarily printing errors without checking
for -1, you can get leftover values in errno.

--

Fletcher Glenn

Barry Margolin

2004-04-19, 6:34 pm

In article <40844372.8010408@removethisfoglight.com>,
Fletcher Glenn <fletcher@removethisfoglight.com> wrote:

> Ole Jacob Hagen wrote:
>
> perror or strerror will not produce meaningful errors unless read
> returns -1. If you are arbitrarily printing errors without checking
> for -1, you can get leftover values in errno.


Another common mistake is to call some other functions in between
calling read() and calling perror(), e.g.

nread = read(...);
if (nread == -1) {
printf("read() returned an error.\n");
perror(...);
}

The problem with this is that the functions that printf() calls
internally may modify errno. So you end up printing the message that
goes with that value, rather than the errno value that was set by
read(). If you must call other functions before calling perror(), you
have to save the original error; you can do this either by saving and
restoring the value of errno, or by calling strerror() to save the error
message string.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com