PageRenderTime 48ms CodeModel.GetById 2ms app.highlight 35ms RepoModel.GetById 1ms app.codeStats 0ms

/core-common-lib/CC3000_Host_Driver/socket.h

https://github.com/vk2tds/Spark_Ethernet
C++ Header | 676 lines | 120 code | 62 blank | 494 comment | 2 complexity | 73554dcc4659c9be1e09dd0be56c77a3 MD5 | raw file
  1/*****************************************************************************
  2*
  3*  socket.h  - CC3000 Host Driver Implementation.
  4*  Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
  5*
  6*  Redistribution and use in source and binary forms, with or without
  7*  modification, are permitted provided that the following conditions
  8*  are met:
  9*
 10*    Redistributions of source code must retain the above copyright
 11*    notice, this list of conditions and the following disclaimer.
 12*
 13*    Redistributions in binary form must reproduce the above copyright
 14*    notice, this list of conditions and the following disclaimer in the
 15*    documentation and/or other materials provided with the   
 16*    distribution.
 17*
 18*    Neither the name of Texas Instruments Incorporated nor the names of
 19*    its contributors may be used to endorse or promote products derived
 20*    from this software without specific prior written permission.
 21*
 22*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
 23*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
 24*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 25*  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
 26*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
 27*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
 28*  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 29*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 30*  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
 31*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
 32*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 33*
 34*****************************************************************************/
 35#ifndef __SOCKET_H__
 36#define __SOCKET_H__
 37
 38
 39//*****************************************************************************
 40//
 41//! \addtogroup socket_api
 42//! @{
 43//
 44//*****************************************************************************
 45
 46
 47//*****************************************************************************
 48//
 49// If building with a C++ compiler, make all of the definitions in this header
 50// have a C binding.
 51//
 52//*****************************************************************************
 53#ifdef  __cplusplus
 54extern "C" {
 55#endif
 56
 57#define HOSTNAME_MAX_LENGTH (230)  // 230 bytes + header shouldn't exceed 8 bit value
 58
 59//--------- Address Families --------
 60
 61#define  AF_INET                2
 62#define  AF_INET6               23
 63
 64//------------ Socket Types ------------
 65
 66#define  SOCK_STREAM            1
 67#define  SOCK_DGRAM             2
 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
 69#define  SOCK_RDM               4
 70#define  SOCK_SEQPACKET         5
 71
 72//----------- Socket Protocol ----------
 73
 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
 83
 84//----------- Socket retunr codes  -----------
 85
 86#define SOC_ERROR				(-1)		// error 
 87#define SOC_IN_PROGRESS			(-2)		// socket in progress
 88
 89//----------- Socket Options -----------
 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
 96
 97#define  MAX_PACKET_SIZE        1500
 98#define  MAX_LISTEN_QUEUE       4
 99
100#define  IOCTL_SOCKET_EVENTMASK
101
102//#define ENOBUFS                 55          // No buffer space available
103
104#define __FD_SETSIZE            32
105
106#define  ASIC_ADDR_LEN          8
107	
108#define NO_QUERY_RECIVED        -3
109	
110	
111typedef struct _in_addr_t
112{
113    UINT32 s_addr;                   // load with inet_aton()
114} in_addr;
115
116typedef struct _sockaddr_t
117{
118    UINT16   sa_family;
119    UINT8     sa_data[14];
120} sockaddr;
121
122typedef struct _sockaddr_in_t
123{
124    INT16            sin_family;            // e.g. AF_INET
125    UINT16   sin_port;              // e.g. htons(3490)
126    in_addr          sin_addr;              // see struct in_addr, below
127    CHAR             sin_zero[8];           // zero this if you want to
128} sockaddr_in;
129
130typedef UINT32 socklen_t;
131
132// The fd_set member is required to be an array of INT32s.
133typedef INT32 __fd_mask;
134
135// It's easier to assume 8-bit bytes than to get CHAR_BIT.
136#define __NFDBITS               (8 * sizeof (__fd_mask))
137#define __FDELT(d)              ((d) / __NFDBITS)
138#define __FDMASK(d)             ((__fd_mask) 1 << ((d) % __NFDBITS))
139
140// fd_set for select and pselect.
141typedef struct
142{
143    __fd_mask fds_bits[__FD_SETSIZE / __NFDBITS];
144#define __FDS_BITS(set)        ((set)->fds_bits)
145} _types_fd_set_cc3000;
146#define fd_set _types_fd_set_cc3000
147
148// We don't use `memset' because this would require a prototype and
149//   the array isn't too big.
150#define __FD_ZERO(set)                               \
151  do {                                                \
152    UINT16 __i;                                 \
153    fd_set *__arr = (set);                            \
154    for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i) \
155      __FDS_BITS (__arr)[__i] = 0;                    \
156  } while (0)
157#define __FD_SET(d, set)       (__FDS_BITS (set)[__FDELT (d)] |= __FDMASK (d))
158#define __FD_CLR(d, set)       (__FDS_BITS (set)[__FDELT (d)] &= ~__FDMASK (d))
159#define __FD_ISSET(d, set)     (__FDS_BITS (set)[__FDELT (d)] & __FDMASK (d))
160
161// Access macros for 'fd_set'.
162#define FD_SET(fd, fdsetp)      __FD_SET (fd, fdsetp)
163#define FD_CLR(fd, fdsetp)      __FD_CLR (fd, fdsetp)
164#define FD_ISSET(fd, fdsetp)    __FD_ISSET (fd, fdsetp)
165#define FD_ZERO(fdsetp)         __FD_ZERO (fdsetp)
166
167//Use in case of Big Endian only
168  
169#define htonl(A)    ((((UINT32)(A) & 0xff000000) >> 24) | \
170                     (((UINT32)(A) & 0x00ff0000) >> 8) | \
171                     (((UINT32)(A) & 0x0000ff00) << 8) | \
172                     (((UINT32)(A) & 0x000000ff) << 24))
173
174#define ntohl                   htonl
175
176//Use in case of Big Endian only
177#define htons(A)     ((((UINT32)(A) & 0xff00) >> 8) | \
178                      (((UINT32)(A) & 0x00ff) << 8))
179
180
181#define ntohs                   htons
182
183// mDNS port - 5353    mDNS multicast address - 224.0.0.251 
184#define SET_mDNS_ADD(sockaddr)     	   	sockaddr.sa_data[0] = 0x14; \
185																								sockaddr.sa_data[1] = 0xe9; \
186																								sockaddr.sa_data[2] = 0xe0; \
187																								sockaddr.sa_data[3] = 0x0; \
188																								sockaddr.sa_data[4] = 0x0; \
189																								sockaddr.sa_data[5] = 0xfb; 
190
191
192//*****************************************************************************
193//
194// Prototypes for the APIs.
195//
196//*****************************************************************************
197
198//*****************************************************************************
199//
200//! socket
201//!
202//!  @param  domain    selects the protocol family which will be used for 
203//!                    communication. On this version only AF_INET is supported
204//!  @param  type      specifies the communication semantics. On this version 
205//!                    only SOCK_STREAM, SOCK_DGRAM, SOCK_RAW are supported
206//!  @param  protocol  specifies a particular protocol to be used with the 
207//!                    socket IPPROTO_TCP, IPPROTO_UDP or IPPROTO_RAW are 
208//!                    supported.
209//!
210//!  @return  On success, socket handle that is used for consequent socket 
211//!           operations. On error, -1 is returned.
212//!
213//!  @brief  create an endpoint for communication
214//!          The socket function creates a socket that is bound to a specific 
215//!          transport service provider. This function is called by the 
216//!          application layer to obtain a socket handle.
217//
218//*****************************************************************************
219extern INT16 socket(INT32 domain, INT32 type, INT32 protocol);
220
221//*****************************************************************************
222//
223//! closesocket
224//!
225//!  @param  sd    socket handle.
226//!
227//!  @return  On success, zero is returned. On error, -1 is returned.
228//!
229//!  @brief  The socket function closes a created socket.
230//
231//*****************************************************************************
232extern INT32 closesocket(INT32 sd);
233
234//*****************************************************************************
235//
236//! accept
237//!
238//!  @param[in]   sd      socket descriptor (handle)              
239//!  @param[out]  addr    the argument addr is a pointer to a sockaddr structure
240//!                       This structure is filled in with the address of the  
241//!                       peer socket, as known to the communications layer.        
242//!                       determined. The exact format of the address returned             
243//!                       addr is by the socket's address sockaddr. 
244//!                       On this version only AF_INET is supported.
245//!                       This argument returns in network order.
246//!  @param[out] addrlen  the addrlen argument is a value-result argument: 
247//!                       it should initially contain the size of the structure
248//!                       pointed to by addr.
249//!
250//!  @return  For socket in blocking mode:
251//!				      On success, socket handle. on failure negative
252//!			      For socket in non-blocking mode:
253//!				     - On connection establishment, socket handle
254//!				     - On connection pending, SOC_IN_PROGRESS (-2)
255//!			       - On failure, SOC_ERROR	(-1)
256//!
257//!  @brief  accept a connection on a socket:
258//!          This function is used with connection-based socket types 
259//!          (SOCK_STREAM). It extracts the first connection request on the 
260//!          queue of pending connections, creates a new connected socket, and
261//!          returns a new file descriptor referring to that socket.
262//!          The newly created socket is not in the listening state. 
263//!          The original socket sd is unaffected by this call. 
264//!          The argument sd is a socket that has been created with socket(),
265//!          bound to a local address with bind(), and is  listening for 
266//!          connections after a listen(). The argument addr is a pointer 
267//!          to a sockaddr structure. This structure is filled in with the 
268//!          address of the peer socket, as known to the communications layer.
269//!          The exact format of the address returned addr is determined by the 
270//!          socket's address family. The addrlen argument is a value-result
271//!          argument: it should initially contain the size of the structure
272//!          pointed to by addr, on return it will contain the actual 
273//!          length (in bytes) of the address returned.
274//!
275//! @sa     socket ; bind ; listen
276//
277//*****************************************************************************
278extern INT32 accept(INT32 sd, sockaddr *addr, socklen_t *addrlen);
279
280//*****************************************************************************
281//
282//! bind
283//!
284//!  @param[in]   sd      socket descriptor (handle)              
285//!  @param[out]  addr    specifies the destination address. On this version 
286//!                       only AF_INET is supported.
287//!  @param[out] addrlen  contains the size of the structure pointed to by addr.
288//!
289//!  @return  	On success, zero is returned. On error, -1 is returned.
290//!
291//!  @brief  assign a name to a socket
292//!          This function gives the socket the local address addr.
293//!          addr is addrlen bytes long. Traditionally, this is called when a 
294//!          socket is created with socket, it exists in a name space (address 
295//!          family) but has no name assigned.
296//!          It is necessary to assign a local address before a SOCK_STREAM
297//!          socket may receive connections.
298//!
299//! @sa     socket ; accept ; listen
300//
301//*****************************************************************************
302extern INT32 bind(INT32 sd, const sockaddr *addr, INT32 addrlen);
303
304//*****************************************************************************
305//
306//! listen
307//!
308//!  @param[in]   sd      socket descriptor (handle)              
309//!  @param[in]  backlog  specifies the listen queue depth. On this version
310//!                       backlog is not supported.
311//!  @return  	On success, zero is returned. On error, -1 is returned.
312//!
313//!  @brief  listen for connections on a socket
314//!          The willingness to accept incoming connections and a queue
315//!          limit for incoming connections are specified with listen(),
316//!          and then the connections are accepted with accept.
317//!          The listen() call applies only to sockets of type SOCK_STREAM
318//!          The backlog parameter defines the maximum length the queue of
319//!          pending connections may grow to. 
320//!
321//! @sa     socket ; accept ; bind
322//!
323//! @note   On this version, backlog is not supported
324//
325//*****************************************************************************
326extern INT32 listen(INT32 sd, INT32 backlog);
327
328//*****************************************************************************
329//
330//! gethostbyname
331//!
332//!  @param[in]   hostname     host name              
333//!  @param[in]   usNameLen    name length 
334//!  @param[out]  out_ip_addr  This parameter is filled in with host IP address. 
335//!                            In case that host name is not resolved, 
336//!                            out_ip_addr is zero.                  
337//!  @return  	On success, positive is returned. On error, negative is returned
338//!
339//!  @brief  Get host IP by name. Obtain the IP Address of machine on network, 
340//!          by its name.
341//!
342//!  @note  On this version, only blocking mode is supported. Also note that
343//!		     the function requires DNS server to be configured prior to its usage.
344//
345//*****************************************************************************
346#ifndef CC3000_TINY_DRIVER 
347extern INT16 gethostbyname(CHAR * hostname, UINT16 usNameLen, UINT32* out_ip_addr);
348#endif
349
350
351//*****************************************************************************
352//
353//! connect
354//!
355//!  @param[in]   sd       socket descriptor (handle)         
356//!  @param[in]   addr     specifies the destination addr. On this version
357//!                        only AF_INET is supported.
358//!  @param[out]  addrlen  contains the size of the structure pointed to by addr    
359//!  @return  	On success, zero is returned. On error, -1 is returned
360//!
361//!  @brief  initiate a connection on a socket 
362//!          Function connects the socket referred to by the socket descriptor 
363//!          sd, to the address specified by addr. The addrlen argument 
364//!          specifies the size of addr. The format of the address in addr is 
365//!          determined by the address space of the socket. If it is of type 
366//!          SOCK_DGRAM, this call specifies the peer with which the socket is 
367//!          to be associated; this address is that to which datagrams are to be
368//!          sent, and the only address from which datagrams are to be received.  
369//!          If the socket is of type SOCK_STREAM, this call attempts to make a 
370//!          connection to another socket. The other socket is specified  by 
371//!          address, which is an address in the communications space of the
372//!          socket. Note that the function implements only blocking behavior 
373//!          thus the caller will be waiting either for the connection 
374//!          establishment or for the connection establishment failure.
375//!
376//!  @sa socket
377//
378//*****************************************************************************
379extern INT32 connect(INT32 sd, const sockaddr *addr, INT32 addrlen);
380
381//*****************************************************************************
382//
383//! select
384//!
385//!  @param[in]   nfds       the highest-numbered file descriptor in any of the
386//!                           three sets, plus 1.     
387//!  @param[out]   writesds   socket descriptors list for write monitoring
388//!  @param[out]   readsds    socket descriptors list for read monitoring  
389//!  @param[out]   exceptsds  socket descriptors list for exception monitoring
390//!  @param[in]   timeout     is an upper bound on the amount of time elapsed
391//!                           before select() returns. Null means infinity 
392//!                           timeout. The minimum timeout is 5 milliseconds,
393//!                          less than 5 milliseconds will be set
394//!                           automatically to 5 milliseconds.
395//!  @return  	On success, select() returns the number of file descriptors
396//!             contained in the three returned descriptor sets (that is, the
397//!             total number of bits that are set in readfds, writefds,
398//!             exceptfds) which may be zero if the timeout expires before
399//!             anything interesting  happens.
400//!             On error, -1 is returned.
401//!                   *readsds - return the sockets on which Read request will
402//!                              return without delay with valid data.
403//!                   *writesds - return the sockets on which Write request 
404//!                                 will return without delay.
405//!                   *exceptsds - return the sockets which closed recently.
406//!
407//!  @brief  Monitor socket activity  
408//!          Select allow a program to monitor multiple file descriptors,
409//!          waiting until one or more of the file descriptors become 
410//!         "ready" for some class of I/O operation 
411//!
412//!  @Note   If the timeout value set to less than 5ms it will automatically set
413//!          to 5ms to prevent overload of the system
414//!
415//!  @sa socket
416//
417//*****************************************************************************
418extern INT16 select(INT32 nfds, fd_set *readsds, fd_set *writesds,
419                  fd_set *exceptsds, struct timeval *timeout);
420
421//*****************************************************************************
422//
423//! setsockopt
424//!
425//!  @param[in]   sd          socket handle
426//!  @param[in]   level       defines the protocol level for this option
427//!  @param[in]   optname     defines the option name to Interrogate
428//!  @param[in]   optval      specifies a value for the option
429//!  @param[in]   optlen      specifies the length of the option value
430//!  @return  	On success, zero is returned. On error, -1 is returned
431//!
432//!  @brief  set socket options
433//!          This function manipulate the options associated with a socket.
434//!          Options may exist at multiple protocol levels; they are always
435//!          present at the uppermost socket level.
436//!          When manipulating socket options the level at which the option 
437//!          resides and the name of the option must be specified.  
438//!          To manipulate options at the socket level, level is specified as 
439//!          SOL_SOCKET. To manipulate options at any other level the protocol 
440//!          number of the appropriate protocol controlling the option is 
441//!          supplied. For example, to indicate that an option is to be 
442//!          interpreted by the TCP protocol, level should be set to the 
443//!          protocol number of TCP; 
444//!          The parameters optval and optlen are used to access optval - 
445//!          use for setsockopt(). For getsockopt() they identify a buffer
446//!          in which the value for the requested option(s) are to 
447//!          be returned. For getsockopt(), optlen is a value-result 
448//!          parameter, initially containing the size of the buffer 
449//!          pointed to by option_value, and modified on return to 
450//!          indicate the actual size of the value returned. If no option 
451//!          value is to be supplied or returned, option_value may be NULL.
452//!
453//!  @Note   On this version the following two socket options are enabled:
454//!    			 The only protocol level supported in this version
455//!          is SOL_SOCKET (level).
456//!		       1. SOCKOPT_RECV_TIMEOUT (optname)
457//!			      SOCKOPT_RECV_TIMEOUT configures recv and recvfrom timeout 
458//!           in milliseconds.
459//!		        In that case optval should be pointer to UINT32.
460//!		       2. SOCKOPT_NONBLOCK (optname). sets the socket non-blocking mode on 
461//!           or off.
462//!		        In that case optval should be SOCK_ON or SOCK_OFF (optval).
463//!
464//!  @sa getsockopt
465//
466//*****************************************************************************
467#ifndef CC3000_TINY_DRIVER 
468extern INT16 setsockopt(INT32 sd, INT32 level, INT32 optname, const void *optval,
469                      socklen_t optlen);
470#endif
471//*****************************************************************************
472//
473//! getsockopt
474//!
475//!  @param[in]   sd          socket handle
476//!  @param[in]   level       defines the protocol level for this option
477//!  @param[in]   optname     defines the option name to Interrogate
478//!  @param[out]   optval      specifies a value for the option
479//!  @param[out]   optlen      specifies the length of the option value
480//!  @return  	On success, zero is returned. On error, -1 is returned
481//!
482//!  @brief  set socket options
483//!          This function manipulate the options associated with a socket.
484//!          Options may exist at multiple protocol levels; they are always
485//!          present at the uppermost socket level.
486//!          When manipulating socket options the level at which the option 
487//!          resides and the name of the option must be specified.  
488//!          To manipulate options at the socket level, level is specified as 
489//!          SOL_SOCKET. To manipulate options at any other level the protocol 
490//!          number of the appropriate protocol controlling the option is 
491//!          supplied. For example, to indicate that an option is to be 
492//!          interpreted by the TCP protocol, level should be set to the 
493//!          protocol number of TCP; 
494//!          The parameters optval and optlen are used to access optval - 
495//!          use for setsockopt(). For getsockopt() they identify a buffer
496//!          in which the value for the requested option(s) are to 
497//!          be returned. For getsockopt(), optlen is a value-result 
498//!          parameter, initially containing the size of the buffer 
499//!          pointed to by option_value, and modified on return to 
500//!          indicate the actual size of the value returned. If no option 
501//!          value is to be supplied or returned, option_value may be NULL.
502//!
503//!  @Note   On this version the following two socket options are enabled:
504//!    			 The only protocol level supported in this version
505//!          is SOL_SOCKET (level).
506//!		       1. SOCKOPT_RECV_TIMEOUT (optname)
507//!			      SOCKOPT_RECV_TIMEOUT configures recv and recvfrom timeout 
508//!           in milliseconds.
509//!		        In that case optval should be pointer to UINT32.
510//!		       2. SOCKOPT_NONBLOCK (optname). sets the socket non-blocking mode on 
511//!           or off.
512//!		        In that case optval should be SOCK_ON or SOCK_OFF (optval).
513//!
514//!  @sa setsockopt
515//
516//*****************************************************************************
517extern INT16 getsockopt(INT32 sd, INT32 level, INT32 optname, void *optval,
518                      socklen_t *optlen);
519
520//*****************************************************************************
521//
522//!  recv
523//!
524//!  @param[in]  sd     socket handle
525//!  @param[out] buf    Points to the buffer where the message should be stored
526//!  @param[in]  len    Specifies the length in bytes of the buffer pointed to 
527//!                     by the buffer argument.
528//!  @param[in] flags   Specifies the type of message reception. 
529//!                     On this version, this parameter is not supported.
530//!
531//!  @return         Return the number of bytes received, or -1 if an error
532//!                  occurred
533//!
534//!  @brief          function receives a message from a connection-mode socket
535//!
536//!  @sa recvfrom
537//!
538//!  @Note On this version, only blocking mode is supported.
539//
540//*****************************************************************************
541extern INT16 recv(INT32 sd, void *buf, INT32 len, INT32 flags);
542
543//*****************************************************************************
544//
545//!  recvfrom
546//!
547//!  @param[in]  sd     socket handle
548//!  @param[out] buf    Points to the buffer where the message should be stored
549//!  @param[in]  len    Specifies the length in bytes of the buffer pointed to 
550//!                     by the buffer argument.
551//!  @param[in] flags   Specifies the type of message reception. 
552//!                     On this version, this parameter is not supported.
553//!  @param[in] from   pointer to an address structure indicating the source
554//!                    address: sockaddr. On this version only AF_INET is
555//!                    supported.
556//!  @param[in] fromlen   source address structure size
557//!
558//!  @return         Return the number of bytes received, or -1 if an error
559//!                  occurred
560//!
561//!  @brief         read data from socket
562//!                 function receives a message from a connection-mode or
563//!                 connectionless-mode socket. Note that raw sockets are not
564//!                 supported.
565//!
566//!  @sa recv
567//!
568//!  @Note On this version, only blocking mode is supported.
569//
570//*****************************************************************************
571extern INT16 recvfrom(INT32 sd, void *buf, INT32 len, INT32 flags, sockaddr *from, 
572                    socklen_t *fromlen);
573
574//*****************************************************************************
575//
576//!  send
577//!
578//!  @param sd       socket handle
579//!  @param buf      Points to a buffer containing the message to be sent
580//!  @param len      message size in bytes
581//!  @param flags    On this version, this parameter is not supported
582//!
583//!  @return         Return the number of bytes transmitted, or -1 if an
584//!                  error occurred
585//!
586//!  @brief          Write data to TCP socket
587//!                  This function is used to transmit a message to another 
588//!                  socket.
589//!
590//!  @Note           On this version, only blocking mode is supported.
591//!
592//!  @sa             sendto
593//
594//*****************************************************************************
595
596extern INT16 send(INT32 sd, const void *buf, INT32 len, INT32 flags);
597
598//*****************************************************************************
599//
600//!  sendto
601//!
602//!  @param sd       socket handle
603//!  @param buf      Points to a buffer containing the message to be sent
604//!  @param len      message size in bytes
605//!  @param flags    On this version, this parameter is not supported
606//!  @param to       pointer to an address structure indicating the destination
607//!                  address: sockaddr. On this version only AF_INET is
608//!                  supported.
609//!  @param tolen    destination address structure size
610//!
611//!  @return         Return the number of bytes transmitted, or -1 if an
612//!                  error occurred
613//!
614//!  @brief          Write data to TCP socket
615//!                  This function is used to transmit a message to another 
616//!                  socket.
617//!
618//!  @Note           On this version, only blocking mode is supported.
619//!
620//!  @sa             send
621//
622//*****************************************************************************
623
624extern INT16 sendto(INT32 sd, const void *buf, INT32 len, INT32 flags, 
625                  const sockaddr *to, socklen_t tolen);
626
627//*****************************************************************************
628//
629//!  mdnsAdvertiser
630//!
631//!  @param[in] mdnsEnabled         flag to enable/disable the mDNS feature
632//!  @param[in] deviceServiceName   Service name as part of the published
633//!                                 canonical domain name
634//!  @param[in] deviceServiceNameLength   Length of the service name - up to 32 chars
635//!  
636//!
637//!  @return   On success, zero is returned, return SOC_ERROR if socket was not 
638//!            opened successfully, or if an error occurred.
639//!
640//!  @brief    Set CC3000 in mDNS advertiser mode in order to advertise itself.
641//
642//*****************************************************************************
643extern INT16 mdnsAdvertiser(UINT16 mdnsEnabled, CHAR * deviceServiceName, UINT16 deviceServiceNameLength);
644
645
646//*****************************************************************************
647//
648//!  getmssvalue
649//!
650//!  @param[in] sd         socket descriptor
651//!
652//!  @return   On success, returns the MSS value of a TCP connection
653//!
654//!  @brief    Returns the MSS value of a TCP connection according to the socket descriptor
655//
656//*****************************************************************************
657extern UINT16 getmssvalue (INT32 sd);
658
659//*****************************************************************************
660//
661// Close the Doxygen group.
662//! @}
663//
664//*****************************************************************************
665
666
667//*****************************************************************************
668//
669// Mark the end of the C bindings section for C++ compilers.
670//
671//*****************************************************************************
672#ifdef  __cplusplus
673}
674#endif // __cplusplus
675
676#endif // __SOCKET_H__