Re: [CODE] Sockets...Anybody? Help?

From: Sean Daley (
Date: 11/10/98

>> Missing a "do"
>Actually,while loops works fine without do commands.
>And the sendcmd function works fine. I dedcided to write my own function
>like write_to_descriptor because that function had no error checking of
>how much data got sent compaired to how much data there was.

I really hate to sound a little rude here, but given how much
time and effort that George has put into the Circlemud code,
I'm sure he knows that while loops work fine without do commands.

Yes, while loops work fine without do commands as long as you
put the while in the right place.  Here is your code as listed
in George' message and what your code "should" actually do.

        bytessent = send(handel, buf, strlen(buf), 0);
        if (bytessent == -1)
                return -1;
        else if (bytessent != strlen(buf)){
                b = 0;
                position += (bytessent + 1);
                for     (a = (bytessent + 1); a < strlen(buf); a++, b++)
                        buf2[b] = buf[a];
                buf2[b + 1] = '\0';
                buf = buf2;
                c = -1;
        else {
                c = bytessent;
} while (c == -1);

The stuff between the first { and the last } is just a block of
code that gets executed once.  it then comes to the
while (c == -1); and executes that once (or many times) depending
on whether or not c == -1.  And if c == -1 your hosed since
this will loop indefinitely.  It's just a while loop that does
nothing  since the statement it's "executing" is the ;

As George said, if you want to put while at the end, start the block
off with a do statement.

Now I don't actually have your original post anymore so I don't
know if you actually had a do in there, but from your response to
George's message I'm assuming you didn't.


     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | |

This archive was generated by hypermail 2b30 : 12/15/00 PST