root / arduino-1.0 / libraries / Ethernet / utility / socket.h @ 58d82c77
History | View | Annotate | Download (1.97 KB)
1 | 58d82c77 | Tom Mullins | #ifndef _SOCKET_H_
|
---|---|---|---|
2 | #define _SOCKET_H_
|
||
3 | |||
4 | #include "w5100.h" |
||
5 | |||
6 | extern uint8_t socket(SOCKET s, uint8_t protocol, uint16_t port, uint8_t flag); // Opens a socket(TCP or UDP or IP_RAW mode) |
||
7 | extern void close(SOCKET s); // Close socket |
||
8 | extern uint8_t connect(SOCKET s, uint8_t * addr, uint16_t port); // Establish TCP connection (Active connection) |
||
9 | extern void disconnect(SOCKET s); // disconnect the connection |
||
10 | extern uint8_t listen(SOCKET s); // Establish TCP connection (Passive connection) |
||
11 | extern uint16_t send(SOCKET s, const uint8_t * buf, uint16_t len); // Send data (TCP) |
||
12 | extern uint16_t recv(SOCKET s, uint8_t * buf, uint16_t len); // Receive data (TCP) |
||
13 | extern uint16_t peek(SOCKET s, uint8_t *buf);
|
||
14 | extern uint16_t sendto(SOCKET s, const uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port); // Send data (UDP/IP RAW) |
||
15 | extern uint16_t recvfrom(SOCKET s, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port); // Receive data (UDP/IP RAW) |
||
16 | |||
17 | extern uint16_t igmpsend(SOCKET s, const uint8_t * buf, uint16_t len); |
||
18 | |||
19 | // Functions to allow buffered UDP send (i.e. where the UDP datagram is built up over a
|
||
20 | // number of calls before being sent
|
||
21 | /*
|
||
22 | @brief This function sets up a UDP datagram, the data for which will be provided by one
|
||
23 | or more calls to bufferData and then finally sent with sendUDP.
|
||
24 | @return 1 if the datagram was successfully set up, or 0 if there was an error
|
||
25 | */
|
||
26 | extern int startUDP(SOCKET s, uint8_t* addr, uint16_t port); |
||
27 | /*
|
||
28 | @brief This function copies up to len bytes of data from buf into a UDP datagram to be
|
||
29 | sent later by sendUDP. Allows datagrams to be built up from a series of bufferData calls.
|
||
30 | @return Number of bytes successfully buffered
|
||
31 | */
|
||
32 | uint16_t bufferData(SOCKET s, uint16_t offset, const uint8_t* buf, uint16_t len);
|
||
33 | /*
|
||
34 | @brief Send a UDP datagram built up from a sequence of startUDP followed by one or more
|
||
35 | calls to bufferData.
|
||
36 | @return 1 if the datagram was successfully sent, or 0 if there was an error
|
||
37 | */
|
||
38 | int sendUDP(SOCKET s);
|
||
39 | |||
40 | #endif
|
||
41 | /* _SOCKET_H_ */ |