57 #define HOSTNAME_MAX_LENGTH (230) // 230 bytes + header shouldn't exceed 8 bit value
68 #define SOCK_RAW 3 // Raw sockets allow new IPv4 protocols to be implemented in user space. A raw socket receives or sends the raw datagram not including link level headers
70 #define SOCK_SEQPACKET 5
74 #define IPPROTO_IP 0 // dummy for IP
75 #define IPPROTO_ICMP 1 // control message protocol
76 #define IPPROTO_IPV4 IPPROTO_IP // IP inside IP
77 #define IPPROTO_TCP 6 // tcp
78 #define IPPROTO_UDP 17 // user datagram protocol
79 #define IPPROTO_IPV6 41 // IPv6 in IPv6
80 #define IPPROTO_NONE 59 // No next header
81 #define IPPROTO_RAW 255 // raw IP packet
82 #define IPPROTO_MAX 256
86 #define SOC_ERROR (-1) // error
87 #define SOC_IN_PROGRESS (-2) // socket in progress
90 #define SOL_SOCKET 0xffff // socket level
91 #define SOCKOPT_RECV_NONBLOCK 0 // recv non block mode, set SOCK_ON or SOCK_OFF (default block mode)
92 #define SOCKOPT_RECV_TIMEOUT 1 // optname to configure recv and recvfromtimeout
93 #define SOCKOPT_ACCEPT_NONBLOCK 2 // accept non block mode, set SOCK_ON or SOCK_OFF (default block mode)
94 #define SOCK_ON 0 // socket non-blocking mode is enabled
95 #define SOCK_OFF 1 // socket blocking mode is enabled
97 #define MAX_PACKET_SIZE 1500
98 #define MAX_LISTEN_QUEUE 4
100 #define IOCTL_SOCKET_EVENTMASK
102 #define ENOBUFS 55 // No buffer space available
104 #define __FD_SETSIZE 32
106 #define ASIC_ADDR_LEN 8
108 #define NO_QUERY_RECIVED -3
130 typedef UINT32 socklen_t;
133 typedef INT32 __fd_mask;
136 #define __NFDBITS (8 * sizeof (__fd_mask))
137 #define __FDELT(d) ((d) / __NFDBITS)
138 #define __FDMASK(d) ((__fd_mask) 1 << ((d) % __NFDBITS))
143 __fd_mask fds_bits[__FD_SETSIZE / __NFDBITS];
144 #define __FDS_BITS(set) ((set)->fds_bits)
149 #define __FD_ZERO(set) \
152 fd_set *__arr = (set); \
153 for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i) \
154 __FDS_BITS (__arr)[__i] = 0; \
156 #define __FD_SET(d, set) (__FDS_BITS (set)[__FDELT (d)] |= __FDMASK (d))
157 #define __FD_CLR(d, set) (__FDS_BITS (set)[__FDELT (d)] &= ~__FDMASK (d))
158 #define __FD_ISSET(d, set) (__FDS_BITS (set)[__FDELT (d)] & __FDMASK (d))
161 #define FD_SET(fd, fdsetp) __FD_SET (fd, fdsetp)
162 #define FD_CLR(fd, fdsetp) __FD_CLR (fd, fdsetp)
163 #define FD_ISSET(fd, fdsetp) __FD_ISSET (fd, fdsetp)
164 #define FD_ZERO(fdsetp) __FD_ZERO (fdsetp)
168 #define htonl(A) ((((UINT32)(A) & 0xff000000) >> 24) | \
169 (((UINT32)(A) & 0x00ff0000) >> 8) | \
170 (((UINT32)(A) & 0x0000ff00) << 8) | \
171 (((UINT32)(A) & 0x000000ff) << 24))
176 #define htons(A) ((((UINT32)(A) & 0xff00) >> 8) | \
177 (((UINT32)(A) & 0x00ff) << 8))
183 #define SET_mDNS_ADD(sockaddr) sockaddr.sa_data[0] = 0x14; \
184 sockaddr.sa_data[1] = 0xe9; \
185 sockaddr.sa_data[2] = 0xe0; \
186 sockaddr.sa_data[3] = 0x0; \
187 sockaddr.sa_data[4] = 0x0; \
188 sockaddr.sa_data[5] = 0xfb;
218 extern INT16
socket(INT32 domain, INT32 type, INT32 protocol);
277 extern INT32
accept(INT32 sd,
sockaddr *addr, socklen_t *addrlen);
301 extern INT32
bind(INT32 sd,
const sockaddr *addr, INT32 addrlen);
325 extern INT32
listen(INT32 sd, INT32 backlog);
345 #ifndef CC3000_TINY_DRIVER
346 extern INT16
gethostbyname(CHAR * hostname, UINT16 usNameLen, UINT32* out_ip_addr);
466 #ifndef CC3000_TINY_DRIVER
467 extern INT16
setsockopt(INT32 sd, INT32 level, INT32 optname,
const void *optval,
516 extern INT16
getsockopt(INT32 sd, INT32 level, INT32 optname,
void *optval,
540 extern INT16
recv(INT32 sd,
void *buf, INT32 len, INT32 flags);
570 extern INT16
recvfrom(INT32 sd,
void *buf, INT32 len, INT32 flags,
sockaddr *from,
595 extern INT16
send(INT32 sd,
const void *buf, INT32 len, INT32 flags);
623 extern INT16
sendto(INT32 sd,
const void *buf, INT32 len, INT32 flags,
624 const sockaddr *to, socklen_t tolen);
642 extern INT16
mdnsAdvertiser(UINT16 mdnsEnabled, CHAR * deviceServiceName, UINT16 deviceServiceNameLength);
673 #endif // __cplusplus
675 #endif // __SOCKET_H__
INT32 connect(INT32 sd, const sockaddr *addr, INT32 addrlen)
initiate a connection on a socket Function connects the socket referred to by the socket descriptor s...
Definition: socket.c:523
INT32 listen(INT32 sd, INT32 backlog)
listen for connections on a socket The willingness to accept incoming connections and a queue limit f...
Definition: socket.c:413
INT16 mdnsAdvertiser(UINT16 mdnsEnabled, CHAR *deviceServiceName, UINT16 deviceServiceNameLength)
Set CC3000 in mDNS advertiser mode in order to advertise itself.
Definition: socket.c:1124
INT32 closesocket(INT32 sd)
The socket function closes a created socket.
Definition: socket.c:226
INT16 select(INT32 nfds, fd_set *readsds, fd_set *writesds, fd_set *exceptsds, struct timeval *timeout)
Monitor socket activity Select allow a program to monitor multiple file descriptors, waiting until one or more of the file descriptors become "ready" for some class of I/O operation.
Definition: socket.c:590
INT16 recv(INT32 sd, void *buf, INT32 len, INT32 flags)
function receives a message from a connection-mode socket
Definition: socket.c:906
INT16 setsockopt(INT32 sd, INT32 level, INT32 optname, const void *optval, socklen_t optlen)
set socket options This function manipulate the options associated with a socket. Options may exist a...
Definition: socket.c:714
INT16 getsockopt(INT32 sd, INT32 level, INT32 optname, void *optval, socklen_t *optlen)
set socket options This function manipulate the options associated with a socket. Options may exist a...
Definition: socket.c:797
Definition: cc3000_common.h:168
INT32 accept(INT32 sd, sockaddr *addr, socklen_t *addrlen)
accept a connection on a socket: This function is used with connection-based socket types (SOCK_STREA...
Definition: socket.c:298
INT16 gethostbyname(CHAR *hostname, UINT16 usNameLen, UINT32 *out_ip_addr)
Get host IP by name. Obtain the IP Address of machine on network, by its name.
Definition: socket.c:457
INT32 bind(INT32 sd, const sockaddr *addr, INT32 addrlen)
assign a name to a socket This function gives the socket the local address addr. addr is addrlen byte...
Definition: socket.c:361
INT16 socket(INT32 domain, INT32 type, INT32 protocol)
create an endpoint for communication The socket function creates a socket that is bound to a specific...
Definition: socket.c:186
UINT16 getmssvalue(INT32 sd)
Returns the MSS value of a TCP connection according to the socket descriptor.
Definition: socket.c:1165
INT16 sendto(INT32 sd, const void *buf, INT32 len, INT32 flags, const sockaddr *to, socklen_t tolen)
Write data to TCP socket This function is used to transmit a message to another socket.
Definition: socket.c:1101
INT16 recvfrom(INT32 sd, void *buf, INT32 len, INT32 flags, sockaddr *from, socklen_t *fromlen)
read data from socket function receives a message from a connection-mode or connectionless-mode socke...
Definition: socket.c:939
INT16 send(INT32 sd, const void *buf, INT32 len, INT32 flags)
Write data to TCP socket This function is used to transmit a message to another socket.
Definition: socket.c:1070