15 #ifndef __SOCKET_UDP_H__
16 #define __SOCKET_UDP_H__
18 #include "socket_udp_incoming.h"
37 inline bool Send(
const char * data,
int len);
39 inline bool Send(
const string &data);
52 static void init_type() {
53 Socket_UDP_Incoming::init_type();
54 register_type(_type_handle,
"Socket_UDP",
55 Socket_UDP_Incoming::get_class_type());
58 return get_class_type();
60 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
75 if (setsockopt(_socket, SOL_SOCKET, SO_BROADCAST, (
char *)&optval,
sizeof(optval)) != 0)
91 if (DO_CONNECT(_socket, &address.GetAddressInfo()) != 0)
106 _socket = DO_NEWUDP();
107 if (_socket == BAD_SOCKET)
123 return (DO_SOCKET_WRITE(_socket, data, len) == len);
135 return Send(data.data(), data.size());
149 return (DO_SOCKET_WRITE_TO(_socket, data, len, &address.GetAddressInfo()) == len);
162 return SendTo(data.data(), data.size(), address);
165 #endif //__SOCKET_UDP_H__
bool InitToAddress(const Socket_Address &address)
Connects the Socket to a Specified address.
bool InitNoAddress()
This will set a udp up for targeted sends.
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 munipulate tcp and port address for communication layer.
void Close()
closes a socket if it is open (allocated)
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 with out a bound external address.
bool SetToBroadCast()
Flips the OS bits that allow for brodcast packets to com in on this port.