Skip to content

Commit

Permalink
wrap connect/bind and test them
Browse files Browse the repository at this point in the history
  • Loading branch information
tsee committed Jun 12, 2010
1 parent ddd4253 commit 050ef4d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
7 changes: 7 additions & 0 deletions ZeroMQ.xsp
Expand Up @@ -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);

};


Expand Down
28 changes: 25 additions & 3 deletions t/01basic.t
Expand Up @@ -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();
Expand All @@ -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.