more published interfaces

This commit is contained in:
David Rose 2007-02-09 17:41:10 +00:00
parent b8bb953a34
commit 79772845e3
3 changed files with 53 additions and 19 deletions

View File

@ -64,9 +64,8 @@ protected:
inline void ClearAll(void);
inline bool SendMessageBufferOnly(Datagram &msg); // do not use this .. this is a way for the the COnnecting UPcall to drop messages in queue first..
public:
inline bool GetMessage(Datagram &val);
PUBLISHED:
inline bool GetMessage(Datagram &val);
inline bool DoConnect(void); // all the real state magic is in here
inline bool IsConnected(void);
inline Buffered_DatagramConnection(bool do_blocking_writes, int rbufsize, int wbufsize, int write_flush_point) ;
@ -245,14 +244,14 @@ inline void Buffered_DatagramConnection::ClearAddresses(void)
_Addresslist.clear();
}
////////////////////////////////////////////////////////////////////
// Function name : Buffered_DatagramConnection::GetMessageInternal
// Function name : Buffered_DatagramConnection::GetMessage
// Description : read a message
//
// false means something bad happened..
//
//
// Return type : inline bool
// Argument : DataGram **val
// Argument : Datagram &val
////////////////////////////////////////////////////////////////////
inline bool Buffered_DatagramConnection::GetMessage(Datagram &val)
{

View File

@ -20,24 +20,24 @@ public:
const AddressType & GetAddressInfo() const { return _addr; }
PUBLISHED:
Socket_Address(short port = 0);
Socket_Address(const Socket_Address &inaddr);
inline Socket_Address(short port = 0);
inline Socket_Address(const Socket_Address &inaddr);
virtual ~Socket_Address();
inline virtual ~Socket_Address();
bool set_any_IP(int port);
bool set_port(int port);
bool set_broadcast(int port);
inline bool set_any_IP(int port);
inline bool set_port(int port);
inline bool set_broadcast(int port);
bool set_host(const std::string &hostname, int port) ;
bool set_host(const std::string &hostname) ;
bool set_host(unsigned int ip4adr, int port);
void clear();
inline bool set_host(const std::string &hostname, int port) ;
inline bool set_host(const std::string &hostname) ;
inline bool set_host(unsigned int ip4adr, int port);
inline void clear();
unsigned short get_port() const;
std::string get_ip() const ;
std::string get_ip_port() const;
unsigned long GetIPAddressRaw() const;
inline unsigned short get_port() const;
inline std::string get_ip() const ;
inline std::string get_ip_port() const;
inline unsigned long GetIPAddressRaw() const;
inline bool operator== (const Socket_Address &in) const;
inline bool operator < (const Socket_Address &in) const;

View File

@ -12,12 +12,20 @@ class EXPCL_PANDA Socket_UDP_Outgoing : public Socket_IP
{
public:
PUBLISHED:
inline Socket_UDP_Outgoing() { }
// use this interface for a tagreted UDP connection
inline bool InitToAddress(Socket_Address & address);
public:
inline bool Send(const char * data, int len);
PUBLISHED:
inline bool Send(const string &data);
// use this interface for a none tagreted UDP connection
inline bool InitNoAddress();
public:
inline bool SendTo(const char * data, int len, const Socket_Address & address);
PUBLISHED:
inline bool SendTo(const string &data, const Socket_Address & address);
inline bool SetToBroadCast();
};
//////////////////////////////////////////////////////////////
@ -67,6 +75,7 @@ inline bool Socket_UDP_Outgoing::InitNoAddress()
return true;
}
////////////////////////////////////////////////////////////////////
// Function name : Socket_UDP_Outgoing::Send
// Description : Send data to connected address
@ -79,6 +88,19 @@ inline bool Socket_UDP_Outgoing::Send(const char * data, int len)
{
return (DO_SOCKET_WRITE(_socket, data, len) == len);
}
////////////////////////////////////////////////////////////////////
// Function name : Socket_UDP_Outgoing::Send
// Description : Send data to connected address
//
// Return type : inline bool
// Argument : const string &data
////////////////////////////////////////////////////////////////////
inline bool Socket_UDP_Outgoing::Send(const string &data)
{
return Send(data.data(), data.size());
}
////////////////////////////////////////////////////////////////////
// Function name : Socket_UDP_Outgoing::SendTo
// Description : Send data to specified address
@ -93,4 +115,17 @@ inline bool Socket_UDP_Outgoing::SendTo(const char * data, int len, const Socket
return (DO_SOCKET_WRITE_TO(_socket, data, len, &address.GetAddressInfo()) == len);
}
////////////////////////////////////////////////////////////////////
// Function name : Socket_UDP_Outgoing::SendTo
// Description : Send data to specified address
//
// Return type : inline bool
// Argument : const string &data
// Argument : NetAddress & address
////////////////////////////////////////////////////////////////////
inline bool Socket_UDP_Outgoing::SendTo(const string &data, const Socket_Address & address)
{
return SendTo(data.data(), data.size(), address);
}
#endif //__SOCKET_UDP_OUTGOING_H__