/** send to specified address */ void UdpSocket::SendToBuf(const std::string& h, port_t p, const char *data, int len, int flags) { #ifdef ENABLE_IPV6 #ifdef IPPROTO_IPV6 if (IsIpv6()) { Ipv6Address ad(h, p); if (ad.IsValid()) { SendToBuf(ad, data, len, flags); } return; } #endif #endif Ipv4Address ad(h, p); if (ad.IsValid()) { SendToBuf(ad, data, len, flags); } }
int rawsend( char *data, int size, short cmd, int sock_index ) { char sendbuf[2048]; char bakbuf[2048]; *((short *)bakbuf) = size+2; *((short *)(bakbuf+2)) = cmd; memcpy( bakbuf+4, data, size ); #ifndef NONECODE netcode_encode( sock_index, sendbuf, bakbuf, size+4 ); #else memcpy( sendbuf, bakbuf, size+4 ); #endif SendToBuf( sendbuf, size+4, sock_index ); g_send_num++; return 0; }
void UdpSocket::SendTo(SocketAddress& ad, const std::string& str, int flags) { SendToBuf(ad, str.c_str(), (int)str.size(), flags); }
void UdpSocket::SendTo(in6_addr a, port_t p, const std::string& str, int flags) { SendToBuf(a, p, str.c_str(), (int)str.size(), flags); }
void UdpSocket::SendToBuf(in6_addr a, port_t p, const char *data, int len, int flags) { Ipv6Address ad(a, p); SendToBuf(ad, data, len, flags); }