Skip to Content.
Sympa Menu

transport - Re: [transport] API comments

Subject: Transport protocols and bulk file transfer

List archive

Re: [transport] API comments


Chronological Thread 
  • From: Yunhong Gu <>
  • To:
  • Subject: Re: [transport] API comments
  • Date: Fri, 25 Feb 2005 00:31:24 -0600 (CST)


Maybe this is going to be a little off-topic?

> X_SOCKET s;
> X_ERROR_T errcode;
> s = x_socket(...);
again, s need to be checked to see if it is valid, otherwise the following
code, including x_sockerror(s) may be problematic.

> x_connect(s, ...);

if the above operation fails, doing the following is simply a waste of CPU
time, not to mention that certain application may do a lot of data
processing before the data are sent out.

> x_sendfile(s, ...);

if this is x_recv(s, ...);
and if the return value is not checked, the received data can be junk and
cause problems like segmetation fault when processing the received data.

> x_close(s);
> errcode = x_sockerror(s);
> if (errcode) {
> x_whine_about(errcode);
> exit(1);
> }
>

for this special case, i.e., sendfile, the code above is ok, except for
the x_socket error checking. I agree here that a socket specific error
checking is useful in certain situations. it sometimes is also helpful
when programmers forgot to do error checking somewhere in the program.

So this is an advantage, and the disadvantage is that addition stuff such
as x_socketerr(LAST_ERROR) still needs to be defined, and such kind of
error checking will encourage people to delay or omit some error checking,
which sometimes is not good, as I mentioned in the above example.

Gu



Archive powered by MHonArc 2.6.16.

Top of Page