Skip to content

Commit a219c61

Browse files
committed
EthernetClient - availableForWrite() implementation
1 parent f22ec8b commit a219c61

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/EthernetClient.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,18 @@ UIPClient::_write(uip_userdata_t* u, const uint8_t *buf, size_t size)
228228
return 0;
229229
}
230230

231+
int
232+
UIPClient::availableForWrite()
233+
{
234+
const int MAX_AVAILABLE = UIP_SOCKET_DATALEN * UIP_SOCKET_NUMPACKETS;
235+
UIPEthernetClass::tick();
236+
if (data->packets_out[0] == NOBLOCK)
237+
return MAX_AVAILABLE;
238+
uint8_t p = _currentBlock(data->packets_out);
239+
int used = UIP_SOCKET_DATALEN * p + data->out_pos;
240+
return MAX_AVAILABLE - used;
241+
}
242+
231243
void
232244
UIPClient::flush()
233245
{

src/EthernetClient.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class EthernetClient : public Client {
6666

6767
size_t write(uint8_t);
6868
size_t write(const uint8_t *buf, size_t size);
69+
int availableForWrite();
6970
void flush(); // flush sends the buffered data
7071

7172
int available();

0 commit comments

Comments
 (0)