remove uint8_t * from the send path of the socket API

This commit is contained in:
Mathieu Lacage
2007-08-01 19:19:42 +02:00
parent 1b62aa5a79
commit b954d65b8f
7 changed files with 16 additions and 51 deletions

View File

@@ -186,8 +186,7 @@ PacketSocket::Connect(const Address &ad)
}
int
PacketSocket::Send (const uint8_t* buffer,
uint32_t size)
PacketSocket::Send (const Packet &p)
{
if (m_state == STATE_OPEN ||
m_state == STATE_BOUND)
@@ -195,13 +194,11 @@ PacketSocket::Send (const uint8_t* buffer,
m_errno = ERROR_NOTCONN;
return -1;
}
return SendTo (m_destAddr, buffer, size);
return SendTo (m_destAddr, p);
}
int
PacketSocket::SendTo(const Address &address,
const uint8_t *buffer,
uint32_t size)
PacketSocket::SendTo(const Address &address, const Packet &p)
{
PacketSocketAddress ad;
if (m_state == STATE_CLOSED)
@@ -226,16 +223,6 @@ PacketSocket::SendTo(const Address &address,
return -1;
}
ad = PacketSocketAddress::ConvertFrom (address);
Packet p;
if (buffer == 0)
{
p = Packet (size);
}
else
{
p = Packet (buffer, size);
}
bool error = false;
Address dest = ad.GetPhysicalAddress ();

View File

@@ -82,8 +82,8 @@ public:
virtual int ShutdownSend (void);
virtual int ShutdownRecv (void);
virtual int Connect(const Address &address);
virtual int Send (const uint8_t* buffer, uint32_t size);
virtual int SendTo(const Address &address,const uint8_t *buffer, uint32_t size);
virtual int Send (const Packet &p);
virtual int SendTo(const Address &address,const Packet &p);
private:

View File

@@ -169,24 +169,22 @@ public:
/**
* \brief Send data (or dummy data) to the remote host
* \param buffer Data to send (nil if dummy data).
* \param size Number of bytes to send.
* \param p packet to send
* \param dataSent Data sent callback.
* \returns -1 in case of error or the number of bytes copied in the
* internal buffer and accepted for transmission.
*/
virtual int Send (const uint8_t* buffer, uint32_t size) = 0;
virtual int Send (const Packet &p) = 0;
/**
* \brief Send data to a specified peer.
* \param address IP Address of remote host
* \param buffer Data to send (nil if dummy data).
* \param size Number of bytes to send.
* \param p packet to send
* \param dataSent Data sent callback.
* \returns -1 in case of error or the number of bytes copied in the
* internal buffer and accepted for transmission.
*/
virtual int SendTo(const Address &address,const uint8_t *buffer, uint32_t size) = 0;
virtual int SendTo(const Address &address,const Packet &p) = 0;
protected:
void NotifyCloseCompleted (void);