TizenRT Libs&Environment  v2.0 M2
socket.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright 2016 Samsung Electronics All Rights Reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing,
12  * software distributed under the License is distributed on an
13  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14  * either express or implied. See the License for the specific
15  * language governing permissions and limitations under the License.
16  *
17  ****************************************************************************/
18 /****************************************************************************
19  * include/sys/socket.h
20  *
21  * Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved.
22  * Author: Gregory Nutt <gnutt@nuttx.org>
23  *
24  * Redistribution and use in source and binary forms, with or without
25  * modification, are permitted provided that the following conditions
26  * are met:
27  *
28  * 1. Redistributions of source code must retain the above copyright
29  * notice, this list of conditions and the following disclaimer.
30  * 2. Redistributions in binary form must reproduce the above copyright
31  * notice, this list of conditions and the following disclaimer in
32  * the documentation and/or other materials provided with the
33  * distribution.
34  * 3. Neither the name NuttX nor the names of its contributors may be
35  * used to endorse or promote products derived from this software
36  * without specific prior written permission.
37  *
38  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
39  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
40  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
41  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
42  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
43  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
44  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
45  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
46  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
47  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
48  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
49  * POSSIBILITY OF SUCH DAMAGE.
50  *
51  ****************************************************************************/
61 #ifndef __INCLUDE_SYS_SOCKET_H
64 #define __INCLUDE_SYS_SOCKET_H
65 
66 /****************************************************************************
67  * Included Files
68  ****************************************************************************/
69 
70 #include <tinyara/config.h>
71 #include <sys/types.h>
72 
73 #ifdef CONFIG_NET_LWIP
74 #include <net/lwip/sockets.h>
75 #include <net/lwip/api.h>
76 #else
77 #include <sys/sock_internal.h>
78 #endif /* CONFIG_NET_LWIP */
79 
80 /****************************************************************************
81  * Public Function Prototypes
82  ****************************************************************************/
83 
84 #undef EXTERN
85 #if defined(__cplusplus)
86 #define EXTERN extern "C"
87 extern "C" {
88 #else
89 #define EXTERN extern
90 #endif
91 
104 int socket(int domain, int type, int protocol);
105 
118 int bind(int sockfd, FAR const struct sockaddr *addr, socklen_t addrlen);
119 
132 int connect(int sockfd, FAR const struct sockaddr *addr, socklen_t addrlen);
133 
145 int listen(int sockfd, int backlog);
146 
159 int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
160 
174 ssize_t send(int sockfd, FAR const void *buf, size_t len, int flags);
190 ssize_t sendto(int sockfd, FAR const void *buf, size_t len, int flags, FAR const struct sockaddr *to, socklen_t tolen);
191 
205 ssize_t recv(int sockfd, FAR void *buf, size_t len, int flags);
206 
222 ssize_t recvfrom(int sockfd, FAR void *buf, size_t len, int flags, FAR struct sockaddr *from, FAR socklen_t *fromlen);
223 
235 int shutdown(int sockfd, int how);
236 
237 // @cond
246 int closesocket(int s);
247 // @endcond
248 
263 int setsockopt(int sockfd, int level, int option, FAR const void *value, socklen_t value_len);
264 
279 int getsockopt(int sockfd, int level, int option, FAR void *value, FAR socklen_t *value_len);
291 int getsockname(int sockfd, FAR struct sockaddr *addr, FAR socklen_t *addrlen);
292 
304 int getpeername(int s, struct sockaddr *name, socklen_t *namelen);
305 
306 ssize_t recvmsg(int sockfd, struct msghdr *msg, int flags);
307 ssize_t sendmsg(int sockfd, struct msghdr *msg, int flags);
308 
309 #undef EXTERN
310 #if defined(__cplusplus)
311 }
312 #endif
313 
314 #endif /* __INCLUDE_SYS_SOCKET_H */
315 // end of NETWORK group
int getsockname(int sockfd, FAR struct sockaddr *addr, FAR socklen_t *addrlen)
get the socket name
ssize_t recvmsg(int sockfd, struct msghdr *msg, int flags)
int shutdown(int sockfd, int how)
shut down socket send and receive operations
int listen(int sockfd, int backlog)
listen for socket connections and limit the queue of incoming connections
int getpeername(int s, struct sockaddr *name, socklen_t *namelen)
get the name of the peer socket
ssize_t sendto(int sockfd, FAR const void *buf, size_t len, int flags, FAR const struct sockaddr *to, socklen_t tolen)
send a message on a socket
int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
requests a connection to be made on a socket
ssize_t recvfrom(int sockfd, FAR void *buf, size_t len, int flags, FAR struct sockaddr *from, FAR socklen_t *fromlen)
receive a message from a socket
int socket(int domain, int type, int protocol)
creates an unbound socket in a communications domain.
int bind(int sockfd, FAR const struct sockaddr *addr, socklen_t addrlen)
assigns an address to an unnamed socket.
int getsockopt(int sockfd, int level, int option, FAR void *value, FAR socklen_t *value_len)
get the socket options
ssize_t send(int sockfd, FAR const void *buf, size_t len, int flags)
send a message on a socket
ssize_t sendmsg(int sockfd, struct msghdr *msg, int flags)
int setsockopt(int sockfd, int level, int option, FAR const void *value, socklen_t value_len)
set the socket options
int connect(int sockfd, FAR const struct sockaddr *addr, socklen_t addrlen)
requests a connection to be made on a socket
ssize_t recv(int sockfd, FAR void *buf, size_t len, int flags)
send a message on a socket