Add uint8_t* based API for sockets

This commit is contained in:
Raj Bhattacharjea committed 2007-12-13 09:40:21 -05:00
1 parent 8e1dd91b8c
commit b9d8c0ebff
2 files changed
+55

No files matched your search

+30
View File
@@ -78,6 +78,36 @@ Socket::SetRecvCallback (Callback<void, Ptr<Socket>, Ptr<Packet>,const Address&>
m_receivedData = receivedData;
}
int Socket::Send (const uint8_t* buf, uint32_t size)
{
NS_LOG_FUNCTION;
Ptr<Packet> p;
if (buf)
{
p = Create<Packet> (buf, size);
}
else
{
p = Create<Packet> (size);
}
return Send (p);
}
int Socket::SendTo (const Address &address, const uint8_t* buf, uint32_t size)
{
NS_LOG_FUNCTION;
Ptr<Packet> p;
if(buf)
{
p = Create<Packet> (buf, size);
}
else
{
p = Create<Packet> (size);
}
return SendTo (address,p);
}
void
Socket::NotifyCloseCompleted (void)
{
+25
View File
@@ -176,6 +176,17 @@ public:
*/
virtual int Send (Ptr<Packet> p) = 0;
/**
* \brief Send data (or dummy data) to the remote host
* \param buf A pointer to a raw byte buffer of some data to send. If this
* is 0, we send dummy data whose size is specified by the second parameter
* \param size the number of bytes to copy from the buffer
*
* This is provided so as to have an API which is closer in appearance
* to that of real network or BSD sockets.
*/
int Send (const uint8_t* buf, uint32_t size);
/**
* \brief Send data to a specified peer.
* \param address IP Address of remote host
@@ -185,6 +196,20 @@ public:
*/
virtual int SendTo(const Address &address,Ptr<Packet> p) = 0;
/**
* \brief Send data to a specified peer.
* \param address IP Address of remote host
* \param buf A pointer to a raw byte buffer of some data to send. If this
* is 0, we send dummy data whose size is specified by the third parameter
* \param size the number of bytes to copy from the buffer
* \returns -1 in case of error or the number of bytes copied in the
* internal buffer and accepted for transmission.
*
* This is provided so as to have an API which is closer in appearance
* to that of real network or BSD sockets.
*/
int SendTo(const Address &address, const uint8_t* buf, uint32_t size);
protected:
void NotifyCloseCompleted (void);
void NotifyConnectionSucceeded (void);