Documentation for routine close
Documentation for routine close, assembled from the following types:
Channel, normally. This makes subsequent
send calls die with X::Channel::SendOnClosed. Subsequent calls of
.receive may still drain any remaining items that were previously sent, but if the queue is empty, will throw an X::Channel::ReceiveOnClosed exception. A
Seq produced by an
@() or by the
.list method will not terminate until this has been done.
my = Channel.new;.close;.send(1);CATCH ;# OUTPUT: «X::Channel::SendOnClosed: Cannot send a message on a closed channel␤»
Please note that any exception thrown may prevent
.close from being called, this may hang the receiving thread. Use a LEAVE phaser to enforce the
.close call in this case.
To close an open file handle, simply call its close method:
my = open("path-to-file");# ... do stuff with the file.close;
It is also possible to call this as a sub, thus the example above can be written equivalently like so:
my = open("path-to-file");# ... do stuff with the fileclose ;
When a file was opened for writing, closing it is important to ensure that all contents are actually written to the file. You may want to consider using a LEAVE phaser to guard against exceptions in your code that could prevent your program from reaching the line with
Will close a previously opened filehandle.
method close(IO::Pipe: --> Proc)
Closes the pipe and returns Proc object from which the pipe originates.
Closes the socket.
Fails if the socket is not connected.
In order to close the underlying listening socket created by
listen you can
close the Tap. See
listen for examples.
Closes the tap.