1 #ifndef __SOCKET_UDP_OUTGOING_H__
2 #define __SOCKET_UDP_OUTGOING_H__
17 inline bool Send(
const char *data,
int len);
19 inline bool Send(
const std::string &data);
21 inline bool InitNoAddress();
23 inline bool SendTo(
const char *data,
int len,
const Socket_Address &address);
25 inline bool SendTo(
const std::string &data,
const Socket_Address &address);
26 inline bool SetToBroadCast();
32 static void init_type() {
33 Socket_IP::init_type();
35 Socket_IP::get_class_type());
38 return get_class_type();
40 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
53 if (setsockopt(_socket, SOL_SOCKET, SO_BROADCAST, (
char *)&optval,
sizeof(optval)) != 0) {
68 if (DO_CONNECT(_socket, &address.GetAddressInfo()) != 0) {
81 _socket = DO_NEWUDP(AF_INET);
82 if (_socket == BAD_SOCKET) {
93 Send(
const char *data,
int len) {
94 return (DO_SOCKET_WRITE(_socket, data, len) == len);
101 Send(
const std::string &data) {
102 return Send(data.data(), data.size());
110 return (DO_SOCKET_WRITE_TO(_socket, data, len, &address.GetAddressInfo()) == len);
118 return SendTo(data.data(), data.size(), address);
A simple place to store and manipulate tcp and port address for communication layer.
Base functionality for a INET domain Socket This call should be the starting point for all other unix...
void Close()
Closes a socket if it is open (allocated).
Base functionality for a UDP sending socket.
bool SendTo(const char *data, int len, const Socket_Address &address)
Send data to specified address.
bool Send(const char *data, int len)
Send data to connected address.
bool SetToBroadCast()
Ask the OS to let us receive broadcast packets on this port.
bool InitToAddress(const Socket_Address &address)
Connects the Socket to a specified address.
bool InitNoAddress()
This will set a udp up for targeted sends.
TypeHandle is the identifier used to differentiate C++ class types.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...