• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ s_sendmsg函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中s_sendmsg函数的典型用法代码示例。如果您正苦于以下问题:C++ s_sendmsg函数的具体用法?C++ s_sendmsg怎么用?C++ s_sendmsg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了s_sendmsg函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: zmq_sendiov

// Send multiple messages.
//
// If flag bit ZMQ_SNDMORE is set the vector is treated as
// a single multi-part message, i.e. the last message has
// ZMQ_SNDMORE bit switched off.
//
int zmq_sendiov (void *s_, iovec *a_, size_t count_, int flags_)
{
    if (!s_ || !((zmq::socket_base_t*) s_)->check_tag ()) {
        errno = ENOTSOCK;
        return -1;
    }
    int rc = 0;
    zmq_msg_t msg;
    zmq::socket_base_t *s = (zmq::socket_base_t *) s_;
    
    for (size_t i = 0; i < count_; ++i) {
        rc = zmq_msg_init_size (&msg, a_[i].iov_len);
        if (rc != 0) {
            rc = -1;
            break;
        }
        memcpy (zmq_msg_data (&msg), a_[i].iov_base, a_[i].iov_len);
        if (i == count_ - 1)
            flags_ = flags_ & ~ZMQ_SNDMORE;
        rc = s_sendmsg (s, &msg, flags_);
        if (unlikely (rc < 0)) {
           int err = errno;
           int rc2 = zmq_msg_close (&msg);
           errno_assert (rc2 == 0);
           errno = err;
           rc = -1;
           break;
        }
    }
    return rc; 
}
开发者ID:gparmer,项目名称:libzmq,代码行数:37,代码来源:zmq.cpp


示例2: zmq_msg_send

int zmq_msg_send (zmq_msg_t *msg_, void *s_, int flags_)
{
    zmq::socket_base_t *s = as_socket_base_t (s_);
    if (!s)
        return -1;
    return s_sendmsg (s, msg_, flags_);
}
开发者ID:zeromq,项目名称:libzmq,代码行数:7,代码来源:zmq.cpp


示例3: zmq_send

int zmq_send (void *s_, const void *buf_, size_t len_, int flags_)
{
    if (!s_ || !((zmq::socket_base_t*) s_)->check_tag ()) {
        errno = ENOTSOCK;
        return -1;
    }
    zmq_msg_t msg;
    int rc = zmq_msg_init_size (&msg, len_);
    if (rc != 0)
        return -1;
    memcpy (zmq_msg_data (&msg), buf_, len_);

    zmq::socket_base_t *s = (zmq::socket_base_t *) s_;
    rc = s_sendmsg (s, &msg, flags_);
    if (unlikely (rc < 0)) {
        int err = errno;
        int rc2 = zmq_msg_close (&msg);
        errno_assert (rc2 == 0);
        errno = err;
        return -1;
    }
    
    //  Note the optimisation here. We don't close the msg object as it is
    //  empty anyway. This may change when implementation of zmq_msg_t changes.
    return rc;
}
开发者ID:gparmer,项目名称:libzmq,代码行数:26,代码来源:zmq.cpp


示例4: zmq_send

int zmq_send (void *s_, const void *buf_, size_t len_, int flags_)
{
    zmq::socket_base_t *s = as_socket_base_t (s_);
    if (!s)
        return -1;
    zmq_msg_t msg;
    if (zmq_msg_init_size (&msg, len_))
        return -1;

    //  We explicitly allow a send from NULL, size zero
    if (len_) {
        assert (buf_);
        memcpy (zmq_msg_data (&msg), buf_, len_);
    }
    int rc = s_sendmsg (s, &msg, flags_);
    if (unlikely (rc < 0)) {
        int err = errno;
        int rc2 = zmq_msg_close (&msg);
        errno_assert (rc2 == 0);
        errno = err;
        return -1;
    }
    //  Note the optimisation here. We don't close the msg object as it is
    //  empty anyway. This may change when implementation of zmq_msg_t changes.
    return rc;
}
开发者ID:zeromq,项目名称:libzmq,代码行数:26,代码来源:zmq.cpp


示例5: serv_kill_client

void serv_kill_client (serverchan *sc,s_client *al)
{
 s_client *bl;
 mestyp b;

 if (al!=NULL) {
  //Client rausschmei˜en...
  b=MESEXITSERVER;
  if (sendto (sc->fd, &b, sizeof(mestyp), 0, (struct sockaddr *) &al->a,
       						sizeof (struct sockaddr)) < 0) {
   debug_print ("Send Error!\n");
   return;
  }

  // Aus Liste löschen...
#ifdef PAS_RECV
  s_sendmsg (sc,al,32,2,0,0);
#endif
  if (sc->first==al)
   sc->first=al->next;
  else {
   for (bl=sc->first;bl->next!=al;bl=bl->next);
   bl->next=al->next;
  }
  free (al->buf);
  free (al);
 }
}
开发者ID:BackupTheBerlios,项目名称:pop,代码行数:28,代码来源:messnet.c


示例6: zmq_msg_send

int zmq_msg_send (zmq_msg_t *msg_, void *s_, int flags_)
{
    if (!s_ || !((zmq::socket_base_t*) s_)->check_tag ()) {
        errno = ENOTSOCK;
        return -1;
    }
    zmq::socket_base_t *s = (zmq::socket_base_t *) s_;
    int result = s_sendmsg (s, msg_, flags_);
    return result;
}
开发者ID:gparmer,项目名称:libzmq,代码行数:10,代码来源:zmq.cpp


示例7: s_decompr_int

void __INLINE__ s_decompr_int (serverchan *c,s_client *a,char *buf)
{
 int n,g,arg1,arg2;
 messheader *h=(messheader *) buf;
 int *data=(int *) (h+1);

 n=h->num;g=h->group;
 arg1=data[0];arg2=data[1];
 s_sendmsg (c,a,g,n,arg1,arg2);
}
开发者ID:BackupTheBerlios,项目名称:pop,代码行数:10,代码来源:messnet.c


示例8: zmq_send_const

int zmq_send_const (void *s_, const void *buf_, size_t len_, int flags_)
{
    zmq::socket_base_t *s = as_socket_base_t (s_);
    if (!s)
        return -1;
    zmq_msg_t msg;
    int rc =
      zmq_msg_init_data (&msg, const_cast<void *> (buf_), len_, NULL, NULL);
    if (rc != 0)
        return -1;

    rc = s_sendmsg (s, &msg, flags_);
    if (unlikely (rc < 0)) {
        int err = errno;
        int rc2 = zmq_msg_close (&msg);
        errno_assert (rc2 == 0);
        errno = err;
        return -1;
    }
    //  Note the optimisation here. We don't close the msg object as it is
    //  empty anyway. This may change when implementation of zmq_msg_t changes.
    return rc;
}
开发者ID:zeromq,项目名称:libzmq,代码行数:23,代码来源:zmq.cpp


示例9: calcserv

// Server Main Loop...
void calcserv(serverchan *sc)
{
 struct sockaddr_in taddr;
 sock_size_t addrlength; // I hate these different types in different envs
 char gbuf[MAXBUF];
 int gbuflen,gbufpos,datalen;
 int i;
 mestyp b;
 s_client *al,*bl;

 // Messages empfangen
 addrlength=sizeof(struct sockaddr_in);
 while ((gbuflen=recvfrom (sc->fd, gbuf, MAXBUF, 0, (struct sockaddr *) &taddr,
        					&addrlength)) > 0) {
  gbufpos=0;
  // Client suchen
  for (al=sc->first;al!=NULL;al=al->next)
   if (al->a.sin_port==taddr.sin_port && al->a.sin_addr.s_addr==taddr.sin_addr.s_addr)
    break;

  if (al!=NULL || (*((mestyp *) (gbuf+gbufpos))==MESNEWCLIENT)) {

  while (gbufpos<gbuflen) {
  if (al!=NULL && al->status==1) {
   // Noch Daten erwartet...
   memcpy (al->buf+al->bufpos,gbuf, (gbuflen-gbufpos)<al->rest ? (gbuflen-gbufpos) : al->rest);

   if ( (gbuflen-gbufpos) <al->rest) {
     al->bufpos+=gbuflen-gbufpos;
     gbufpos=0;
   } else {
    switch (al->aktion) {
     case MT_INTEGER:
      s_decompr_int (sc,al,al->buf);
      break;
     case MT_STRING:
      s_decompr_str (sc,al,al->buf);
      break;
     case MT_DATA:
      s_decompr_dat (sc,al,al->buf);
      break;
     default:
      debug_print ("seltsamer Fehler!\n");
     }
    al->bufpos=0;
    al->aktion=0;
    al->status=0;

    gbufpos+=al->rest;
   }
  } else {

  // Aktion herausfinden
  if (al!=NULL && al->status!=0) {
   b=al->status;
  } else {
   b=*((mestyp *) (gbuf+gbufpos));
   gbufpos+=sizeof(mestyp);
  }

  switch ( b ) {
   case MESNEWCLIENT:
    // An Liste anh„ngen...
    if (al==NULL) {
     if (sc->acpt_client) {
      al=sc->first;
      sc->first= (s_client *) malloc (sizeof(s_client));
      sc->first->buf=(char *) malloc(MAXBUF);
      sc->first->bufpos=0;
      sc->first->status=0;
      sc->first->rest=0;
      sc->first->aktion=0;

      sc->first->a=taddr;
      sc->first->next=al;
      al=sc->first;

      // Accept Message
      b=MESACPTCLIENT;
      if (sendto (sc->fd, &b, sizeof(mestyp), 0, (struct sockaddr *) &taddr,
         						addrlength) < 0) {
       debug_print ("Send Error!\n");
       return;
      }
      debug_print ("Client accepted!\n");
#ifdef PAS_RECV
      s_sendmsg (sc,sc->first,32,1,0,0);
#endif
     } else {
      //Client rausschmei˜en...
      b=MESDENYCLIENT;
      if (sendto (sc->fd, &b, sizeof(mestyp), 0, (struct sockaddr *) &taddr,
          						addrlength) < 0) {
       debug_print ("Send Error!\n");
       return;
      }
      debug_print ("Client denied!\n");
     }
    } else debug_print ("Double Accepting!\n");
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:pop,代码行数:101,代码来源:messnet.c



注:本文中的s_sendmsg函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ s_strdup函数代码示例发布时间:2022-05-30
下一篇:
C++ s_send函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap