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

Function socket

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

* @brief This Socket function initialize the channel in perticular mode, and set the port and wait for w5500 done it. * @return 1 for success else 0. */

Source from the content-addressed store, hash-verified

14 * @return 1 for success else 0.
15 */
16uint8_t socket(SOCKET s, uint8_t protocol, uint16_t port, uint8_t flag)
17{
18 if ((protocol == SnMR::TCP) || (protocol == SnMR::UDP) || (protocol == SnMR::IPRAW) || (protocol == SnMR::MACRAW) || (protocol == SnMR::PPPOE))
19 {
20 close(s);
21 w5500.writeSnMR(s, protocol | flag);
22 if (port != 0) {
23 w5500.writeSnPORT(s, port);
24 }
25 else {
26 local_port++; // if don't set the source port, set local_port number.
27 w5500.writeSnPORT(s, local_port);
28 }
29
30 w5500.execCmdSn(s, Sock_OPEN);
31
32 return 1;
33 }
34
35 return 0;
36}
37
38
39/**

Callers 3

connectMethod · 0.50
beginMethod · 0.50
beginMethod · 0.50

Calls 2

execCmdSnMethod · 0.80
closeFunction · 0.70

Tested by

no test coverage detected