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

C++ byte_zero函数代码示例

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

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



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

示例1: doit

static int doit(char *q,char qtype[2],char ip[4])
{
    int r;
    uint32 dlen;
    unsigned int qlen;

    qlen = dns_domain_length(q);
    if (qlen > 255) return 0; /* impossible */

    if (byte_diff(qtype,2,DNS_T_A) && byte_diff(qtype,2,DNS_T_ANY)) goto REFUSE;

    key[0] = '%';
    byte_copy(key + 1,4,ip);

    r = cdb_find(&c,key,5);
    if (!r) r = cdb_find(&c,key,4);
    if (!r) r = cdb_find(&c,key,3);
    if (!r) r = cdb_find(&c,key,2);
    if (r == -1) return 0;

    key[0] = '+';
    byte_zero(key + 1,2);
    if (r && (cdb_datalen(&c) == 2))
        if (cdb_read(&c,key + 1,2,cdb_datapos(&c)) == -1) return 0;

    byte_copy(key + 3,qlen,q);
    case_lowerb(key + 3,qlen + 3);

    r = cdb_find(&c,key,qlen + 3);
    if (!r) {
        byte_zero(key + 1,2);
        r = cdb_find(&c,key,qlen + 3);
    }
    if (!r) goto REFUSE;
    if (r == -1) return 0;
    dlen = cdb_datalen(&c);

    if (dlen > 512) dlen = 512;
    if (cdb_read(&c,data,dlen,cdb_datapos(&c)) == -1) return 0;

    dns_sortip(data,dlen);

    if (dlen > 12) dlen = 12;
    while (dlen >= 4) {
        dlen -= 4;
        if (!response_rstart(q,DNS_T_A,"\0\0\0\5")) return 0;
        if (!response_addbytes(data + dlen,4)) return 0;
        response_rfinish(RESPONSE_ANSWER);
    }

    return 1;


REFUSE:
    response[2] &= ~4;
    response[3] &= ~15;
    response[3] |= 5;
    return 1;
}
开发者ID:kjseefried,项目名称:didentd,代码行数:59,代码来源:pickdns.c


示例2: main

int main(void) {

    unsigned char b1[32];
    unsigned char b2[32];
    long long i, j;
    const char *x = "abcdefgh";
    char y[8];

    /* byte_zero test */
    for (i = 0; i < 32; ++i) {
        for (j = 0; j < sizeof b1; ++j) b1[j] = 0;
        for (j = 0; j < sizeof b2; ++j) b2[j] = 0;
        b1[i] = 0xff; b2[i] = 0xff;
        byte_zero(b1, sizeof b1);

        if (byte_isequal(b1, 32, b2) != 0) fail("byte_zero failure");
    }

    /* byte_isequal test */
    for (i = 0; i < sizeof b1; ++i) b1[i] = 0xff;
    for (i = 0; i < sizeof b2; ++i) b2[i] = 0xff;

    if (byte_isequal(b1, 32, b2) == 0) fail("byte_isequal failure");

    for (i = 0; i < 32; ++i) {
        b1[i] = 0;
        if (byte_isequal(b1, 32, b2) != 0) fail("byte_isequal failure");
        b1[i] = 0xff;
    }

    /* byte_copy test */
    for (i = 0; i < sizeof b1; ++i) b1[i] = 0xff;
    for (i = 0; i < sizeof b2; ++i) b2[i] = 0x00;

    byte_copy(b1, 32, b2);
    if (byte_isequal(b1, 32, b2) == 0) fail("byte_copy failure");
    
    for (i = 0; i < 32; ++i) {
        b1[i] = 0;
        byte_copy(b1, 32, b2);
        if (byte_isequal(b1, 32, b2) == 0) fail("byte_copy failure");
        b1[i] = 0xff;
    }

    byte_zero(y, 8);
    if (!byte_isequal(y, 8, "\0\0\0\0\0\0\0\0")) fail("byte_zero/byte_isequal failure");

    byte_copy(y, 8, x);
    if (!byte_isequal(y, 8, x)) fail("byte_copy/byte_isequal failure");

    byte_copy(y, 7, y + 1);
    if (!byte_isequal(y, 8, "bcdefghh")) fail("byte_copy/byte_isequal failure");

    byte_zero(y, 8);
    if (!byte_isequal(y, 8, "\0\0\0\0\0\0\0\0")) fail("byte_zero/byte_isequal failure");

    return 0;
}
开发者ID:LlsDimple,项目名称:tinyssh,代码行数:58,代码来源:bytetest.c


示例3: doanddie

void doanddie(char *user, unsigned int userlen /* including 0 byte */,
    char *pass)
{
  int child;
  int wstat;
  int pi[2];
 
  close(3);
  if (pipe(pi) == -1) die_pipe();
  if (pi[0] != 3) die_pipe();
  switch(child = fork()) {
    case -1:
      die_fork();
    case 0:
      close(pi[1]);
      sig_pipedefault();
      execvp(*childargs,childargs);
      _exit(1);
  }
  close(pi[0]);
  substdio_fdbuf(&ssup,subwrite,pi[1],upbuf,sizeof upbuf);
  if (substdio_put(&ssup,user,userlen) == -1) die_write();
  if (substdio_put(&ssup,pass,str_len(pass) + 1) == -1) die_write();
  if (substdio_puts(&ssup,"<") == -1) die_write();
  if (substdio_puts(&ssup,unique) == -1) die_write();
  if (substdio_puts(&ssup,hostname) == -1) die_write();
  if (substdio_put(&ssup,">",2) == -1) die_write();
  if (substdio_flush(&ssup) == -1) die_write();
  close(pi[1]);
  byte_zero(pass,str_len(pass));
  byte_zero(upbuf,sizeof upbuf);
  if (wait_pid(&wstat,child) == -1) die();
  if (wait_crashed(wstat)) die_childcrashed();
  switch (wait_exitcode(wstat)) {
    case 0: die();
    case 1: die_1();
    case 2: die_2();
    case 25: die_25();
    case 3: die_3();
    case 4: die_4();
    case 5: die_5();
    case 6: die_6();
    case 61: die_61();
    case 62: die_62();
    case 7: die_7();
    case 8: die_nomem();
    default: die_unknown();
  }
  die();
}
开发者ID:ajtulloch,项目名称:qmail,代码行数:50,代码来源:qmail-popup.c


示例4: tdlookup_init

int tdlookup_init(void)
{
  char *x;
  char ch;
  int i;
  int j;
  int k;

  x = env_get("LAME_A");
  if (x)
    if (!ip4_scan(x,lameip))
      byte_zero(lameip,4);

  x = env_get("LAME_MX");
  if (x)
    if (!dns_domain_fromdot(&lamemx,x,str_len(x)))
      return 0;

  x = env_get("LAME_TXT");
  if (x) {
    i = 0;
    j = str_len(x);
    while (i < j) {
      k = j - i;
      if (k > 255) k = 255;
      ch = k;
      if (!stralloc_append(&lametxt,&ch)) return 0;
      if (!stralloc_catb(&lametxt,x + i,k)) return 0;
      i += k;
    }
  }

  return 1;
}
开发者ID:gislik,项目名称:djbdns-1.05g,代码行数:34,代码来源:tdlookup.c


示例5: socket_send6

ssize_t socket_send6(int s,const char *buf,size_t len,const char ip[16],uint16 port,uint32 scope_id)
{
#ifdef LIBC_HAS_IP6
  struct sockaddr_in6 si;
#else
  struct sockaddr_in si;
#endif

  byte_zero(&si,sizeof si);
#ifdef LIBC_HAS_IP6
  if (noipv6) {
#endif
    if (ip6_isv4mapped(ip))
      return socket_send4(s,buf,len,ip+12,port);
    if (byte_equal(ip,16,V6loopback))
      return socket_send4(s,buf,len,ip4loopback,port);
#ifdef LIBC_HAS_IP6
    errno=EPROTONOSUPPORT;
    return -1;
  }
  si.sin6_family = AF_INET6;
  uint16_pack_big((char *) &si.sin6_port,port);
  byte_copy((char *) &si.sin6_addr,16,ip);
#ifdef LIBC_HAS_SCOPE_ID
  si.sin6_scope_id=scope_id;
#else
  si.sin6_scope_id=0;
#endif
  return winsock2errno(sendto(s,buf,len,0,(void*) &si,sizeof si));
#else
  errno=EPROTONOSUPPORT;
  return -1;
#endif
}
开发者ID:Moscarda,项目名称:opentracker-1,代码行数:34,代码来源:socket_send6.c


示例6: socket_connect6

int socket_connect6(int s,const char ip[16],uint16 port,uint32 scope_id)
{
#ifdef LIBC_HAS_IP6
  struct sockaddr_in6 sa;

  if (noipv6) {
#endif
    if (ip6_isv4mapped(ip))
      return socket_connect4(s,ip+12,port);
    if (byte_equal(ip,16,V6loopback))
      return socket_connect4(s,ip4loopback,port);
#ifdef LIBC_HAS_IP6
  }
  byte_zero(&sa,sizeof sa);
  sa.sin6_family = PF_INET6;
  uint16_pack_big((char *) &sa.sin6_port,port);
  sa.sin6_flowinfo = 0;
  sa.sin6_scope_id = scope_id;
  byte_copy((char *) &sa.sin6_addr,16,ip);

  return connect(s,(struct sockaddr *) &sa,sizeof sa);
#else
  errno=EPROTONOSUPPORT;
  return -1;
#endif
}
开发者ID:comotion,项目名称:ucspi-tcp,代码行数:26,代码来源:socket_conn6.c


示例7: byte_zero

PRIVATE char *format_addr6s(const addr6_t addr)
{
    static char s[FORMAT_ADDR6_LEN];
    byte_zero(s, sizeof s);
    format_addr6(s, addr);
    return s;
}
开发者ID:tehmaze,项目名称:libcommon,代码行数:7,代码来源:ip.c


示例8: socket_send6

int socket_send6(int s,const char *buf,unsigned int len,const char ip[16],uint16 port,uint32 scope_id)
{
#ifdef LIBC_HAS_IP6
    struct sockaddr_in6 sa;
#else
    struct sockaddr_in sa;
#endif

    byte_zero(&sa,sizeof sa);
#ifdef LIBC_HAS_IP6
    if (noipv6) {
#endif
        if (ip6_isv4mapped(ip))
            return socket_send4(s,buf,len,ip+12,port);
        if (byte_equal(ip,16,V6loopback))
            return socket_send4(s,buf,len,ip4loopback,port);
#ifdef LIBC_HAS_IP6
        errno=error_proto;
        return -1;
    }
    sa.sin6_family = AF_INET6;
    uint16_pack_big((char *) &sa.sin6_port,port);
    byte_copy((char *) &sa.sin6_addr,16,ip);
    return sendto(s,buf,len,0,(struct sockaddr *) &sa,sizeof sa);
#else
        errno=error_proto;
        return -1;
#endif
}
开发者ID:comotion,项目名称:ucspi-tcp,代码行数:29,代码来源:socket_send6.c


示例9: socket_send4

int
socket_send4 (int s, char *buf, int len,
                const char ip[4], uint16 port, void *src)
{
    char cbuf[256];
    struct iovec iov;
    struct msghdr msgh;
    struct sockaddr_in sa;
    struct cmsghdr *cmsg = NULL;

    byte_zero (&sa, sizeof (sa));
    sa.sin_family = AF_INET;

    uint16_pack_big ((char *)&sa.sin_port, port);
    byte_copy ((char *)&sa.sin_addr, 4, ip);

    memset (cbuf, 0, sizeof (cbuf));
    memset (&msgh, 0, sizeof (msgh));

    iov.iov_len = len;
    iov.iov_base = buf;

    msgh.msg_iov = &iov;
    msgh.msg_iovlen = 1;

    msgh.msg_name = &sa;
    msgh.msg_namelen = sizeof (sa);

#ifdef IP_PKTINFO
    struct in_pktinfo *p = NULL;

    msgh.msg_control = cbuf;
    msgh.msg_controllen = CMSG_SPACE (sizeof (*p));

    cmsg = CMSG_FIRSTHDR (&msgh);
    cmsg->cmsg_type = IP_PKTINFO;
    cmsg->cmsg_level = IPPROTO_IP;
    cmsg->cmsg_len = CMSG_LEN (sizeof (*p));

    p = (struct in_pktinfo *) CMSG_DATA (cmsg);
    p->ipi_spec_dst = *(struct in_addr *)src;
#elif defined IP_SENDSRCADDR
    struct in_addr *p = NULL;

    msgh.msg_control = cbuf;
    msgh.msg_controllen = CMSG_SPACE (sizeof (*p));

    cmsg = CMSG_FIRSTHDR (&msgh);
    cmsg->cmsg_type = IP_SENDSRCADDR;
    cmsg->cmsg_level = IPPROTO_IP;
    cmsg->cmsg_len = CMSG_LEN (sizeof (*p));

    p = (struct in_addr *)CMSG_DATA (cmsg);
    p->s_addr = *(struct in_addr *)src;
#endif

    msgh.msg_flags = 0;
    msgh.msg_controllen = cmsg ? cmsg->cmsg_len : 0;
    return sendmsg (s, &msgh, 0);
}
开发者ID:LordSpacehog,项目名称:ndjbdns,代码行数:60,代码来源:socket_send.c


示例10: countz

/* convert IPv6 address */
static char *iptostr6(char *strbuf, const unsigned char *ip) {

    long long first, last, i;
    unsigned long long ip2[8];
    char *s = strbuf;

    for (i = 7; i >= 0; --i) {
        ip2[i] = ip[2 * i];
        ip2[i] <<= 8;
        ip2[i] += ip[2 * i + 1];
    }

    countz(&first, &last, ip2);

    strbuf += IPTOSTR_LEN - 1;
    *strbuf = 0;

    for (i = 7; i >= 0; --i) {
        if (i <= last && i >= first && first != last) {
            if (i == last) *--strbuf = ':';
            if (i == 7) *--strbuf = ':';
            continue;
        }
        do {
            *--strbuf = "0123456789abcdef"[ip2[i] & 15];
            ip2[i] >>= 4;
        } while (ip2[i]);
        if (i > 0) *--strbuf = ':';
    }
    i = strbuf - s;
    byte_copy(s,  IPTOSTR_LEN - i, strbuf);
    byte_zero(s + IPTOSTR_LEN - i, i);
    return s;
}
开发者ID:LlsDimple,项目名称:tinyssh,代码行数:35,代码来源:iptostr.c


示例11: respond

int respond(char *q,char qtype[2],char ip[4])
{
  int fd;
  int r;
  char key[6];

  tai_now(&now);
  fd = open_read("data.cdb");
  if (fd == -1) return 0;
  cdb_init(&c,fd);

  byte_zero(clientloc,2);
  key[0] = 0;
  key[1] = '%';
  byte_copy(key + 2,4,ip);
  r = cdb_find(&c,key,6);
  if (!r) r = cdb_find(&c,key,5);
  if (!r) r = cdb_find(&c,key,4);
  if (!r) r = cdb_find(&c,key,3);
  if (!r) r = cdb_find(&c,key,2);
  if (r == -1) return 0;
  if (r && (cdb_datalen(&c) == 2))
    if (cdb_read(&c,clientloc,2,cdb_datapos(&c)) == -1) return 0;

  r = doit(q,qtype);

  cdb_free(&c);
  close(fd);
  return r;
}
开发者ID:siddhesh,项目名称:djbdns,代码行数:30,代码来源:tdlookup.c


示例12: socket_recv6

int socket_recv6(int s,char *buf,unsigned int len,char ip[16],uint16 *port,uint32 *scope_id)
{
#ifdef LIBC_HAS_IP6
  struct sockaddr_in6 sa;
#else
  struct sockaddr_in sa;
#endif
  unsigned int dummy = sizeof sa;
  int r;

  byte_zero(&sa,dummy);
  r = recvfrom(s,buf,len,0,(struct sockaddr *) &sa,&dummy);
  if (r == -1) return -1;

#ifdef LIBC_HAS_IP6
  if (noipv6) {
    struct sockaddr_in *sa4=(struct sockaddr_in *)&sa;
    byte_copy(ip,12,V4mappedprefix);
    byte_copy(ip+12,4,(char *) &sa4->sin_addr);
    uint16_unpack_big((char *) &sa4->sin_port,port);
    return r;
  }
  byte_copy(ip,16,(char *) &sa.sin6_addr);
  uint16_unpack_big((char *) &sa.sin6_port,port);
  if (scope_id) *scope_id=sa.sin6_scope_id;
#else
  byte_copy(ip,12,(char *)V4mappedprefix);
  byte_copy(ip+12,4,(char *) &sa.sin_addr);
  uint16_unpack_big((char *) &sa.sin_port,port);
  if (scope_id) *scope_id=0;
#endif

  return r;
}
开发者ID:axlecrusher,项目名称:djbdns,代码行数:34,代码来源:socket_recv6.c


示例13: socket_recv4

int socket_recv4(int s,char *buf,int len,char ip[4],uint16 *port,char dstip[4])
{
  struct sockaddr_in sa;
  int dummy = sizeof sa;
  int r;

  if (dstip == NULL) {
    r = recvfrom(s,buf,len,0,(struct sockaddr *) &sa,&dummy);
    if (r == -1) return -1;
  } else {
    struct iovec iov;
    struct cmsghdr cmsg, *cmsgptr;
    struct msghdr msg;
    char cbuf[64];

    byte_zero(&cmsg, sizeof(cmsg));
    byte_zero(&msg, sizeof(msg));

    iov.iov_base = buf;
    iov.iov_len = len;

    msg.msg_name = &sa;
    msg.msg_namelen = dummy;
    msg.msg_iov = &iov;
    msg.msg_iovlen = 1;
    msg.msg_control = cbuf;
    msg.msg_controllen = sizeof(cbuf);

    r = recvmsg(s, &msg, 0);

    if (r == -1)
      return (-1);

    for (cmsgptr = CMSG_FIRSTHDR(&msg); cmsgptr != NULL; cmsgptr = CMSG_NXTHDR(&msg, cmsgptr)) {
      if (cmsgptr->cmsg_level == SOL_IP && cmsgptr->cmsg_type == IP_PKTINFO) {
        struct in_pktinfo *pki = (struct in_pktinfo *)CMSG_DATA(cmsgptr);
        byte_copy(dstip, 4, (char *)&(pki->ipi_addr));
      }
    }
  }

  byte_copy(ip,4,(char *) &sa.sin_addr);
  uint16_unpack_big((char *) &sa.sin_port,port);

  return r;
}
开发者ID:thcyron,项目名称:djbdns,代码行数:46,代码来源:socket_recv.c


示例14: dns_domain_fromdot_static

int dns_domain_fromdot_static(unsigned char *name,const unsigned char *buf,long long n)
{
  unsigned char label[63];
  long long labellen = 0; /* <= sizeof label */
  long long namelen = 0; /* <= sizeof name */
  unsigned char ch;

  errno = EPROTO;
  if (n < 0) return 0;
  byte_zero(name, 256);

  for (;;) {
    if (!n) break;
    ch = *buf++; --n;
    if (ch == '.') {
      if (labellen > 0) {
        if (namelen + labellen + 1 > 255) return 0;
        name[namelen++] = labellen;
        byte_copy(name + namelen,labellen,label);
        namelen += labellen;
        labellen = 0;
      }
      continue;
    }
    if (ch == '\\') {
      if (!n) break;
      ch = *buf++; --n;
      if ((ch >= '0') && (ch <= '7')) {
        ch -= '0';
        if (n && (*buf >= '0') && (*buf <= '7')) {
          ch <<= 3;
          ch += *buf - '0';
          ++buf; --n;
          if (n && (*buf >= '0') && (*buf <= '7')) {
            ch <<= 3;
            ch += *buf - '0';
            ++buf; --n;
          }
        }
      }
    }
    if (labellen >= sizeof label) return 0;
    label[labellen++] = ch;
  }

  if (labellen > 0) {
    if (namelen + labellen + 1 > 255) return 0;
    name[namelen++] = labellen;
    byte_copy(name + namelen,labellen,label);
    namelen += labellen;
    labellen = 0;
  }

  if (namelen + 1 > 255) return 0;
  name[namelen++] = 0;

  return 1;
}
开发者ID:stribika,项目名称:curveprotect,代码行数:58,代码来源:dns_domain.c


示例15: stats_top_txt

/* Fetches stats from tracker */
size_t stats_top_txt( char * reply, int amount ) {
  size_t    j;
  ot_record top100s[100], top100c[100];
  char     *r  = reply, hex_out[42];
  int       idx, bucket;

  if( amount > 100 )
    amount = 100;

  byte_zero( top100s, sizeof( top100s ) );
  byte_zero( top100c, sizeof( top100c ) );

  for( bucket=0; bucket<OT_BUCKET_COUNT; ++bucket ) {
    ot_vector *torrents_list = mutex_bucket_lock( bucket );
    for( j=0; j<torrents_list->size; ++j ) {
      ot_peerlist *peer_list = ( ((ot_torrent*)(torrents_list->data))[j] ).peer_list;
      int idx = amount - 1; while( (idx >= 0) && ( peer_list->peer_count > top100c[idx].val ) ) --idx;
      if ( idx++ != amount - 1 ) {
        memmove( top100c + idx + 1, top100c + idx, ( amount - 1 - idx ) * sizeof( ot_record ) );
        top100c[idx].val = peer_list->peer_count;
        top100c[idx].torrent = (ot_torrent*)(torrents_list->data) + j;
      }
      idx = amount - 1; while( (idx >= 0) && ( peer_list->seed_count > top100s[idx].val ) ) --idx;
      if ( idx++ != amount - 1 ) {
        memmove( top100s + idx + 1, top100s + idx, ( amount - 1 - idx ) * sizeof( ot_record ) );
        top100s[idx].val = peer_list->seed_count;
        top100s[idx].torrent = (ot_torrent*)(torrents_list->data) + j;
      }
    }
    mutex_bucket_unlock( bucket, 0 );
    if( !g_opentracker_running )
      return 0;
  }

  r += sprintf( r, "Top %d torrents by peers:\n", amount );
  for( idx=0; idx<amount; ++idx )
    if( top100c[idx].torrent )
      r += sprintf( r, "\t%zd\t%s\n", top100c[idx].val, to_hex( hex_out, top100c[idx].torrent->hash) );
  r += sprintf( r, "Top %d torrents by seeds:\n", amount );
  for( idx=0; idx<amount; ++idx )
    if( top100s[idx].torrent )
      r += sprintf( r, "\t%zd\t%s\n", top100s[idx].val, to_hex( hex_out, top100s[idx].torrent->hash) );

  return r - reply;
}
开发者ID:SpiderX,项目名称:opentracker,代码行数:46,代码来源:ot_stats.c


示例16: sha512_final

void sha512_final (SHA512Schedule *ctx, char *digest)
{
  register unsigned int i = 0 ;
  register unsigned int pad = ctx->len % 128;

  ctx->buf[pad++] = 0x80 ;
  if (pad > 112)
  {
    byte_zero(ctx->buf + pad, 128 - pad) ;
    sha512_transform(ctx, ctx->buf) ;
    pad = 0 ;
  }
  byte_zero(ctx->buf + pad, 120 - pad) ;
  uint64_pack_big((char *)ctx->buf + 120, ctx->len << 3) ;
  sha512_transform(ctx, ctx->buf) ;

  for (; i < 8 ; i++) uint64_pack_big(digest + (i << 3), ctx->h[i]) ;
}
开发者ID:fvigotti,项目名称:skalibs,代码行数:18,代码来源:sha512_final.c


示例17: http_init

void
http_init(http* h, const char* host, uint16 port) {
  byte_zero(h, sizeof(http));
  h->sock = -1;
  stralloc_init(&h->host);
  stralloc_copys(&h->host, host);
  h->port = port;
  h->request = NULL;
}
开发者ID:rsenn,项目名称:dirlist,代码行数:9,代码来源:http_init.c


示例18: socket_bind

int socket_bind(int fd,const unsigned char *ip,const unsigned char *port)
{
  struct sockaddr_in sa;
  byte_zero(&sa,sizeof sa);
  sa.sin_family = PF_INET;
  byte_copy(&sa.sin_addr,4,ip);
  byte_copy(&sa.sin_port,2,port);
  return bind(fd,(struct sockaddr *) &sa,sizeof sa);
}
开发者ID:Lipski,项目名称:dnscrypt-proxy,代码行数:9,代码来源:socket_bind.c


示例19: socket_send4

ssize_t socket_send4(int s,const char *buf,size_t len,const char ip[4],uint16 port) {
  struct sockaddr_in si;

  byte_zero(&si,sizeof si);
  si.sin_family = AF_INET;
  uint16_pack_big((char*) &si.sin_port,port);
  *((uint32*)&si.sin_addr) = *((uint32*)ip);
  return winsock2errno(sendto(s,buf,len,0,(void*) &si,sizeof si));
}
开发者ID:Moscarda,项目名称:opentracker-1,代码行数:9,代码来源:socket_send4.c


示例20: socket_connect4

int
socket_connect4(int s, const char* ip, uint16 port) {
  struct sockaddr_in si;
  byte_zero(&si, sizeof(si));
  si.sin_family = AF_INET;
  uint16_pack_big((char*)&si.sin_port, port);
  *((uint32*)&si.sin_addr) = *((uint32*)ip);
  return winsock2errno(connect(s, (struct sockaddr*)&si, sizeof(si)));
}
开发者ID:rsenn,项目名称:dirlist,代码行数:9,代码来源:socket_connect4.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ bytein函数代码示例发布时间:2022-05-30
下一篇:
C++ byte_offset_of函数代码示例发布时间: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