Skip to content
Browse files

wrap connect/bind and test them

  • Loading branch information...
1 parent ddd4253 commit 050ef4d6799962e4fbbb0500574e086a04e1d09e @tsee tsee committed
Showing with 32 additions and 3 deletions.
  1. +7 −0 ZeroMQ.xsp
  2. +25 −3 t/01basic.t
View
7 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);
+
};
View
28 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();

0 comments on commit 050ef4d

Please sign in to comment.
Something went wrong with that request. Please try again.