PageRenderTime 22ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 0ms

/libraries/Wirefree/socket.h

https://github.com/abzman/arduino-libraries
C Header | 46 lines | 20 code | 7 blank | 19 comment | 0 complexity | 2c8b0cc0330a47c4b41679405db8f0a2 MD5 | raw file
Possible License(s): BSD-3-Clause, GPL-2.0
  1. /*
  2. socket.h - network socket class
  3. Copyright (C) 2011 DIYSandbox LLC
  4. This program is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU General Public License
  6. as published by the Free Software Foundation; either version 2
  7. of the License, or (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  15. */
  16. #ifndef _socket_h_
  17. #define _socket_h_
  18. #include "gs.h"
  19. 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)
  20. extern void close(SOCKET s); // Close socket
  21. extern uint8_t listen(SOCKET s); // Establish TCP connection (Passive connection)
  22. extern uint16_t recv(SOCKET s, uint8_t * buf, uint16_t len); // Receive data (TCP)
  23. extern void disconnect(SOCKET s);
  24. extern uint16_t send(SOCKET s, const uint8_t * buf, uint16_t len); // Send data (TCP)
  25. extern uint8_t connect(SOCKET s, String addr, String port);
  26. #if 0
  27. extern uint8_t connect(SOCKET s, uint8_t * addr, uint16_t port); // Establish TCP connection (Active connection)
  28. extern void disconnect(SOCKET s); // disconnect the connection
  29. extern uint16_t send(SOCKET s, const uint8_t * buf, uint16_t len); // Send data (TCP)
  30. extern uint16_t peek(SOCKET s, uint8_t *buf);
  31. extern uint16_t sendto(SOCKET s, const uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port); // Send data (UDP/IP RAW)
  32. extern uint16_t recvfrom(SOCKET s, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port); // Receive data (UDP/IP RAW)
  33. extern uint16_t igmpsend(SOCKET s, const uint8_t * buf, uint16_t len);
  34. #endif
  35. #endif // _socket_h_