diff --git a/ZeroMQ.xsp b/ZeroMQ.xsp index 179fe54..c8beb78 100644 --- a/ZeroMQ.xsp +++ b/ZeroMQ.xsp @@ -19,6 +19,13 @@ class socket_t { %name{new} socket_t(context_t& context, int type); ~socket_t(); + + //void socket_t::getsockopt(int option_name, void *option_value, size_t *option_len) + //void socket_t::setsockopt(int option_name, const void *option_value, size_t option_len) + + void bind(char* endpoint); + void connect(const char *endpoint); + }; diff --git a/t/01basic.t b/t/01basic.t index a5b5416..e1c8757 100644 --- a/t/01basic.t +++ b/t/01basic.t @@ -2,7 +2,7 @@ use strict; use warnings; use File::Spec; -use Test::More tests => 8; +use Test::More tests => 13; use ZeroMQ qw/:all/; pass(); @@ -21,9 +21,31 @@ pass(); { - my $cxt = ZeroMQ::Context->new(1); + my $cxt = ZeroMQ::Context->new(0); # must be 0 theads for in-process bind isa_ok($cxt, 'ZeroMQ::Context'); - my $sock = ZeroMQ::Socket->new($cxt, ZMQ_REQ); # "client" style request socket + my $sock = ZeroMQ::Socket->new($cxt, ZMQ_REP); # server like reply socket isa_ok($sock, 'ZeroMQ::Socket'); + + { # too early, server socket not created: + my $client = ZeroMQ::Socket->new($cxt, ZMQ_REQ); # "client" style request socket + eval { $client->connect("inproc://myPrivateSocket"); }; + ok($@ && "$@" =~ /Connection refused/); + } + + $sock->bind("inproc://myPrivateSocket"); + pass(); + + my $client = ZeroMQ::Socket->new($cxt, ZMQ_REQ); # "client" style request socket + $client->connect("inproc://myPrivateSocket"); + pass(); + +} +pass(); + +{ + my $cxt = ZeroMQ::Context->new(0); # must be 0 theads for in-process bind + my $sock = ZeroMQ::Socket->new($cxt, ZMQ_REP); # server like reply socket + eval {$sock->bind("bulls***");}; + ok($@ && "$@" =~ /Invalid argument/); } pass();