PageRenderTime 61ms CodeModel.GetById 31ms RepoModel.GetById 0ms app.codeStats 0ms

/libraries/WiFi/utility/socket.h

https://github.com/gusvielite/Arduino
C Header | 106 lines | 35 code | 9 blank | 62 comment | 0 complexity | f19b1ac2014e888bec0851ea727f81a3 MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0, LGPL-3.0, BSD-3-Clause
  1. /*
  2. socket.h - Library for Arduino Wifi shield.
  3. Copyright (c) 2011-2014 Arduino. All right reserved.
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. This library 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 GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with this library; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  15. */
  16. /*
  17. *
  18. @file socket.h
  19. @brief define function of socket API
  20. *
  21. */
  22. #ifndef _SOCKET_H_
  23. #define _SOCKET_H_
  24. #define TCP_SOCKET 1
  25. #define UDP_SOCKET 2
  26. #define RAW_SOCKET 3
  27. #define SOCK_NOT_AVAIL 255
  28. #include "wl_definitions.h"
  29. /**
  30. * The 8-bit signed data type.
  31. */
  32. typedef char int8;
  33. /**
  34. * The volatile 8-bit signed data type.
  35. */
  36. typedef volatile char vint8;
  37. /**
  38. * The 8-bit unsigned data type.
  39. */
  40. typedef unsigned char uint8;
  41. /**
  42. * The volatile 8-bit unsigned data type.
  43. */
  44. typedef volatile unsigned char vuint8;
  45. /**
  46. * The 16-bit signed data type.
  47. */
  48. typedef int int16;
  49. /**
  50. * The volatile 16-bit signed data type.
  51. */
  52. typedef volatile int vint16;
  53. /**
  54. * The 16-bit unsigned data type.
  55. */
  56. typedef unsigned int uint16;
  57. /**
  58. * The volatile 16-bit unsigned data type.
  59. */
  60. typedef volatile unsigned int vuint16;
  61. /**
  62. * The 32-bit signed data type.
  63. */
  64. typedef long int32;
  65. /**
  66. * The volatile 32-bit signed data type.
  67. */
  68. typedef volatile long vint32;
  69. /**
  70. * The 32-bit unsigned data type.
  71. */
  72. typedef unsigned long uint32;
  73. /**
  74. * The volatile 32-bit unsigned data type.
  75. */
  76. typedef volatile unsigned long vuint32;
  77. /* bsd */
  78. typedef uint8 u_char; /**< 8-bit value */
  79. typedef uint16_t SOCKET;
  80. typedef uint16 u_short; /**< 16-bit value */
  81. typedef uint16 u_int; /**< 16-bit value */
  82. typedef uint32 u_long; /**< 32-bit value */
  83. extern SOCKET socket(uint8 protocol); // Opens a socket(TCP or UDP or IP_RAW mode)
  84. extern void close(SOCKET s); // Close socket
  85. extern uint8 connect(SOCKET s, uint8 * addr, uint16 port); // Establish TCP connection (Active connection)
  86. extern void disconnect(SOCKET s); // disconnect the connection
  87. extern uint8 listen(SOCKET s); // Establish TCP connection (Passive connection)
  88. extern uint16 send(SOCKET s, const uint8 * buf, uint16 len); // Send data (TCP)
  89. extern uint16 recv(SOCKET s, uint8 * buf, uint16 len); // Receive data (TCP)
  90. extern uint16 sendto(SOCKET s, const uint8 * buf, uint16 len, uint8 * addr, uint16 port); // Send data (UDP/IP RAW)
  91. extern uint16 recvfrom(SOCKET s, uint8 * buf, uint16 len, uint8 * addr, uint16 *port); // Receive data (UDP/IP RAW)
  92. extern uint16 igmpsend(SOCKET s, const uint8 * buf, uint16 len);
  93. #endif
  94. /* _SOCKET_H_ */