Skip to content

Instantly share code, notes, and snippets.

@nunorc
Created May 30, 2010 12:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nunorc/418999 to your computer and use it in GitHub Desktop.
Save nunorc/418999 to your computer and use it in GitHub Desktop.
diff --git a/src/core/IO/Socket/INET.pm b/src/core/IO/Socket/INET.pm
index 63d8f4d..9acaf55 100644
--- a/src/core/IO/Socket/INET.pm
+++ b/src/core/IO/Socket/INET.pm
@@ -2,7 +2,7 @@ class IO::Socket::INET is Cool does IO::Socket {
method open (Str $hostname, Int $port) {
- Q:PIR {
+ my $s = Q:PIR {
.include "socket.pasm"
.local pmc sock
.local pmc address
@@ -22,16 +@@ -22,16 +22,22 @@ class IO::Socket::INET is Cool does IO::Socket {
# Create the socket handle
sock = root_new ['parrot';'Socket']
+ $P1 = new 'Integer'
unless sock goto ERR
sock.'socket'(.PIO_PF_INET, .PIO_SOCK_STREAM, .PIO_PROTO_TCP)
# Pack a sockaddr_in structure with IP and port
address = sock.'sockaddr'(hostname, port)
- sock.'connect'(address)
+ $P1 = sock.'connect'(address)
setattribute self, '$!PIO', sock
+ goto DONE
ERR:
- .return (0)
- }
+ $P1 = -1
+ DONE:
+ %r = $P1
+ };
+ unless $s==0 { fail "IO::Socket::INET Couldn't create socket."; }
+ return 1;
$ cat rt69232.p6
say 'begin';
my $s = IO::Socket::INET.new;
$s.open('127.0.0.1', 80);
$s.send('foo');
say 'end';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment