14 #ifndef __SOCKET_UDP_H__ 15 #define __SOCKET_UDP_H__ 17 #include "socket_udp_incoming.h" 32 inline bool Send(
const char *data,
int len);
34 inline bool Send(
const std::string &data);
45 static void init_type() {
46 Socket_UDP_Incoming::init_type();
48 Socket_UDP_Incoming::get_class_type());
51 return get_class_type();
53 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
66 if (setsockopt(_socket, SOL_SOCKET, SO_BROADCAST, (
char *)&optval,
sizeof(optval)) != 0) {
81 if (DO_CONNECT(_socket, &address.GetAddressInfo()) != 0) {
91 Send(
const char *data,
int len) {
92 return (DO_SOCKET_WRITE(_socket, data, len) == len);
99 Send(
const std::string &data) {
100 return Send(data.data(), data.size());
108 return (DO_SOCKET_WRITE_TO(_socket, data, len, &address.GetAddressInfo()) == len);
116 return SendTo(data.data(), data.size(), address);
119 #endif //__SOCKET_UDP_H__ bool InitToAddress(const Socket_Address &address)
Connects the socket to a Specified address.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
bool Send(const char *data, int len)
Send data to connected address.
Base functionality for a combination UDP Reader and Writer.
bool SendTo(const char *data, int len, const Socket_Address &address)
Send data to specified address.
Base functionality for a UDP Reader.
bool SetToBroadCast()
Ask the OS to let us receive broadcast packets on this port.
A simple place to store and manipulate tcp and port address for communication layer.
TypeHandle is the identifier used to differentiate C++ class types.
bool SendTo(const char *data, int len, const Socket_Address &address)
Send data to specified address.
bool InitNoAddress()
Set this socket to work without a bound external address.
bool SetToBroadCast()
Flips the OS bits that allow for brodcast packets to come in on this port.