Server & shutdown calls 
Author Message
 Server & shutdown calls

All - I'm trying to write a client and a server.  The client will be sending
an XML file to the server, and to indicate that it is finished, I wanted to
call shutdown (1) on the socket.  From the client's point of view, the
socket is closed for writing, but open for writing.

I'm using a sample server from the Perl Cookbook as a starting point.  My
problem is that the server can't seem to distinguish between a full close,
and a half close using shutdown (in the unless statement shown below).

Questions -
1. If I call shutdown from the client, will select return the socket as
being valid?
2. If I call shutdown (1) from my client, I assumed that the socket should
still be valid ($rv), however, there won't be any data to read.  If that's
the case, then I shouldn't fall into the unless{} block, correct?

Thanks,
Mark

####################################################################
Here's a snippet of the code I'm trying to use (O removed some extraneous
code).
while (1) {
    # can_read() returns an array of handles that are ready for reading.
    foreach $client ($select->can_read(1)) {

        if ($client == $server) {
            # Accept a new connection
            $client = $server->accept();
            $select->add($client);
        }
        else {
            # Data is waiting on one of the sockets, read the data
            $data = '';
            $rv = $client->recv($data, POSIX::BUFSIZ, 0);

            unless (defined($rv) && length ($data)) {
                # closing the socket
                print "\nReceived a full close\n";
                $select->remove($client);
                close $client;
                next;
              }
        }
    }

Quote:
}



Mon, 01 Mar 2004 20:51:51 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Server/Server & Client/Server

2. Module to shutdown/reboot linux box?

3. trap shutdown signal win32 perl

4. Perl method to detect shutdown status in Windows XP

5. linux shutdown with ctrl-alt-del

6. Power Shutdown Signal Handler

7. Catch system shutdown event in Perl....

8. trap shutdown signal win32 perl

9. Problems with early shutdown of socket

10. BSD shutdown in perl

11. Scheduling my PC's shutdown...

12. PERLFUNC: shutdown - close down just half of a socket connection

 

 
Powered by phpBB® Forum Software