MCPcopy Create free account
hub / github.com/DanielOgorchock/ST_Anything / send

Function send

Arduino/libraries/Ethernet2/src/utility/socket.cpp:102–143  ·  view source on GitHub ↗

* @brief This function used to send the data in TCP mode * @return 1 for success else 0. */

Source from the content-addressed store, hash-verified

100 * @return 1 for success else 0.
101 */
102uint16_t send(SOCKET s, const uint8_t * buf, uint16_t len)
103{
104 uint8_t status=0;
105 uint16_t ret=0;
106 uint16_t freesize=0;
107
108 if (len > w5500.SSIZE)
109 ret = w5500.SSIZE; // check size not to exceed MAX size.
110 else
111 ret = len;
112
113 // if freebuf is available, start.
114 do
115 {
116 freesize = w5500.getTXFreeSize(s);
117 status = w5500.readSnSR(s);
118 if ((status != SnSR::ESTABLISHED) && (status != SnSR::CLOSE_WAIT))
119 {
120 ret = 0;
121 break;
122 }
123 }
124 while (freesize < ret);
125
126 // copy data
127 w5500.send_data_processing(s, (uint8_t *)buf, ret);
128 w5500.execCmdSn(s, Sock_SEND);
129
130 /* +2008.01 bj */
131 while ( (w5500.readSnIR(s) & SnIR::SEND_OK) != SnIR::SEND_OK )
132 {
133 /* m2008.01 [bj] : reduce code */
134 if ( w5500.readSnSR(s) == SnSR::CLOSED )
135 {
136 close(s);
137 return 0;
138 }
139 }
140 /* +2008.01 bj */
141 w5500.writeSnIR(s, SnIR::SEND_OK);
142 return ret;
143}
144
145
146/**

Callers 2

writeMethod · 0.50
_processMethod · 0.50

Calls 4

getTXFreeSizeMethod · 0.80
send_data_processingMethod · 0.80
execCmdSnMethod · 0.80
closeFunction · 0.70

Tested by

no test coverage detected