|
acme
Foundational cross-platform layer of the ca2 framework
|
#include <udp_socket.h>
Public Member Functions | |
| udp_socket (::i32 ibufsz=16384, bool ipv6=false, ::i32 retries=0) | |
| bool | open (struct in6_addr &a, ::networking::port_t port) |
| bool | open (::networking::address *address) |
| void | SendToBuf (const ::scoped_string &scopedstr, ::networking::port_t, const_char_pointer data, ::i32 len, ::i32 flags=0) |
| void | SendToBuf (::networking::address *address, const_char_pointer data, ::i32 len, ::i32 flags=0) |
| void | SendTo (::networking::address *address, const ::scoped_string &scopedstr, ::i32 flags=0) |
| void | write (const void *data, memsize c) |
| void | SetBroadcast (bool b=true) |
| bool | IsBroadcast () |
| void | SetMulticastTTL (::i32 ttl=1) |
| ::i32 | GetMulticastTTL () |
| bool | SetMulticastLoop (bool=true) |
| bool | IsMulticastLoop () |
| void | AddMulticastMembership (const ::scoped_string &scopedstrGroup, const ::scoped_string &scopedstrInterface="0.0.0.0", ::i32 if_index=0) |
| void | DropMulticastMembership (const ::scoped_string &scopedstrGroup, const ::scoped_string &scopedstrInterface="0.0.0.0", ::i32 if_index=0) |
| void | SetMulticastHops (::i32=-1) |
| ::i32 | GetMulticastHops () |
| bool | IsBound () |
| memsize | GetLastSizeWritten () |
| void | SetTimestamp (bool=true) |
Protected Member Functions | |
| udp_socket (const udp_socket &s) | |
| void | OnRead () |
| void | CreateConnection () |
socket implementation for UDP.
| sockets::udp_socket::udp_socket | ( | ::i32 | ibufsz = 16384, |
| bool | ipv6 = false, | ||
| ::i32 | retries = 0 ) |
Constructor. \lparam h base_socket_handler object \lparam ibufsz Maximum i32_size of receive message (extra bytes will be truncated) \lparam ipv6 'true' if this is an ipv6 socket
|
protected |
create before using sendto methods
| memsize sockets::udp_socket::GetLastSizeWritten | ( | ) |
Return Bind port number
| ::i32 sockets::udp_socket::GetMulticastHops | ( | ) |
multicast, ipv6 only
| bool sockets::udp_socket::IsBound | ( | ) |
Returns true if Bind succeeded.
| bool sockets::udp_socket::IsBroadcast | ( | ) |
Check broadcast flag.
| bool sockets::udp_socket::open | ( | ::networking::address * | address | ) |
Define remote host. \lparam ad socket address
| bool sockets::udp_socket::open | ( | struct in6_addr & | a, |
| ::networking::port_t | port ) |
Called when incoming data has been received. \lparam buf Pointer to data \lparam len Length of data \lparam sa Pointer to sockaddr struct of sender \lparam sa_len Length of sockaddr struct */ using socket::OnRawData; virtual void OnRawData(char_pointer buf, memsize len, struct sockaddr * sa, socklen_t sa_len);
/** Called when incoming data has been received and read timestamp is enabled. \lparam buf Pointer to data \lparam len Length of data \lparam sa Pointer to sockaddr struct of sender \lparam sa_len Length of sockaddr struct \lparam ts Timestamp from message */ virtual void OnRawData(char_pointer buf, memsize len, struct sockaddr * sa, socklen_t sa_len, struct timeval * ts);
/** To receive incoming data, call Bind to setup an incoming port. \lparam port Incoming port number \lparam range Port range to try if ports already in use
/** Define remote host. \lparam l Address of remote host \lparam port Port of remote host
| void sockets::udp_socket::SendTo | ( | ::networking::address * | address, |
| const ::scoped_string & | scopedstr, | ||
| ::i32 | flags = 0 ) |
Send string to specified host Send string to specified address */ void SendTo(in_addr, ::networking::port_t, const scoped_string & scopedstr, ::i32 flags = 0); /** Send string to specified ipv6 address */ void SendTo(in6_addr, ::networking::port_t, const scoped_string & scopedstr, ::i32 flags = 0); /** Send string to specified socket address
| void sockets::udp_socket::SendToBuf | ( | ::networking::address * | address, |
| const_char_pointer | data, | ||
| ::i32 | len, | ||
| ::i32 | flags = 0 ) |
Send to specified address Send to specified ipv6 address */ void SendToBuf(const in6_addr & a, ::networking::port_t, const_char_pointer data, ::i32 len, ::i32 flags = 0); /** Send to specified socket address
| void sockets::udp_socket::SendToBuf | ( | const ::scoped_string & | scopedstr, |
| ::networking::port_t | , | ||
| const_char_pointer | data, | ||
| ::i32 | len, | ||
| ::i32 | flags = 0 ) |
Send to specified host
| void sockets::udp_socket::SetBroadcast | ( | bool | b = true | ) |
Send string to connected address. set broadcast
| void sockets::udp_socket::SetMulticastHops | ( | ::i32 | = -1 | ) |
multicast, ipv6 only
| void sockets::udp_socket::SetMulticastTTL | ( | ::i32 | ttl = 1 | ) |
multicast
| void sockets::udp_socket::SetTimestamp | ( | bool | = true | ) |
Also read timestamp information from incoming message
| void sockets::udp_socket::write | ( | const void * | data, |
| memsize | c ) |
Send to connected address