linking fd to pipe identity via socket option

This commit is contained in:
Stoian Ivanov
2014-04-30 16:34:55 +03:00
parent e37c206211
commit fe3e8c5c70
10 changed files with 57 additions and 4 deletions

View File

@@ -133,6 +133,33 @@ int zmq::router_t::xsetsockopt (int option_, const void *optval_,
return -1;
}
int zmq::router_t::xgetsockopt (int option_, const void *optval_,
size_t *optvallen_)
{
switch (option_) {
case ZMQ_IDENTITY_FD:
if (optval_==NULL && optvallen_) {
*optvallen_=sizeof(fd_t);
return 0;
}
if (optval_ && optvallen_ && *optvallen_) {
blob_t identity= blob_t((unsigned char*)optval_,*optvallen_);
outpipes_t::iterator it = outpipes.find (identity);
if (it == outpipes.end() ){
return ENOTSOCK;
}
*((fd_t*)optval_)=it->second.pipe->assoc_fd;
*optvallen_=sizeof(fd_t);
return 0;
}
break;
default:
break;
}
errno = EINVAL;
return -1;
}
void zmq::router_t::xpipe_terminated (pipe_t *pipe_)
{