Skip to content

Commit

Permalink
Merge branch 'gci_closed_socket'
Browse files Browse the repository at this point in the history
  • Loading branch information
Whiteknight committed Dec 1, 2010
2 parents 4159775 + 2a3c7f8 commit aae1ea9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/pmc/socket.pmc
Expand Up @@ -174,6 +174,23 @@ from a port number (integer) and an address (string).
RETURN(PMC * res);
}


/*

=item C<METHOD is_closed()>

Test if the socket is closed.

=cut

*/

METHOD is_closed() {
const INTVAL status = VTABLE_get_bool(INTERP, SELF);
RETURN(INTVAL status);
}


/*

=item C<connect(PMC * address)>
Expand Down
10 changes: 9 additions & 1 deletion t/pmc/socket.t
Expand Up @@ -19,7 +19,7 @@ Tests the Socket PMC.
.sub main :main
.include 'test_more.pir'

plan(18)
plan(19)

test_init()
test_get_fd()
Expand All @@ -28,6 +28,7 @@ Tests the Socket PMC.
test_clone()
test_bool()
test_close()
test_is_closed()
test_tcp_socket()
test_tcp_socket6()
test_raw_tcp_socket()
Expand Down Expand Up @@ -80,6 +81,13 @@ CODE
nok($P0,'A closed Socket returns False')
.end

.sub test_is_closed
new $P0, ['Socket']

$N0 = $P0.'is_closed'()
is($N0, 1, 'Socket is_closed returned 1 to new socket')
.end

.sub test_clone
new $P0, ['Socket']
$P1 = $P0."sockaddr"("localhost", 1234)
Expand Down

0 comments on commit aae1ea9

Please sign in to comment.