Lines Matching defs:socket
31 #include <sys/socket.h>
82 * socket descriptors
87 /* Capabilities of a socket */
107 /* This defines a bitmap big enough for one bit for each socket option */
119 /* This type defines the type of the socket capabilities set */
123 /* This callbacks are socket operations that may be performed on a socket of
128 struct socket; /* Forward reference */
133 CODE int (*si_setup)(FAR struct socket *psock, int protocol);
134 CODE sockcaps_t (*si_sockcaps)(FAR struct socket *psock);
135 CODE void (*si_addref)(FAR struct socket *psock);
136 CODE int (*si_bind)(FAR struct socket *psock,
138 CODE int (*si_getsockname)(FAR struct socket *psock,
140 CODE int (*si_getpeername)(FAR struct socket *psock,
142 CODE int (*si_listen)(FAR struct socket *psock, int backlog);
143 CODE int (*si_connect)(FAR struct socket *psock,
145 CODE int (*si_accept)(FAR struct socket *psock,
147 FAR struct socket *newsock);
148 CODE int (*si_poll)(FAR struct socket *psock,
150 CODE ssize_t (*si_send)(FAR struct socket *psock, FAR const void *buf,
152 CODE ssize_t (*si_sendto)(FAR struct socket *psock, FAR const void *buf,
156 CODE ssize_t (*si_sendfile)(FAR struct socket *psock,
160 CODE ssize_t (*si_recvfrom)(FAR struct socket *psock, FAR void *buf,
163 CODE int (*si_close)(FAR struct socket *psock);
165 CODE int (*si_ioctl)(FAR struct socket *psock, int cmd,
170 /* Each socket refers to a connection structure of type FAR void *. Each
171 * socket type will have a different connection structure type bound to its
180 /* This is the internal representation of a socket reference by a file
186 struct socket
188 int16_t s_crefs; /* Reference count on the socket */
197 sockopt_t s_options; /* Selected socket options */
418 * Check if the socket descriptor is valid for the provided TCB and if it
420 * fdopen() operation when the fdopen() is performed on a socket descriptor.
421 * It simply performs some sanity checking before permitting the socket
435 * Given a socket descriptor, return the underlying socket structure.
438 * sockfd - The socket descriptor index o use.
441 * On success, a reference to the socket structure associated with the
442 * the socket descriptor is returned. NULL is returned on any failure.
446 struct socket *sockfd_socket(int sockfd);
452 * socket() creates an endpoint for communication and returns a socket
456 * domain (see sys/socket.h)
457 * type (see sys/socket.h)
458 * protocol (see sys/socket.h)
459 * psock A pointer to a user allocated socket structure to be
467 * Permission to create a socket of the specified type and/or protocol
478 * Insufficient memory is available. The socket cannot be created until
489 struct socket *psock);
495 * Performs the close operation on socket descriptors
498 * sockfd Socket descriptor of socket
514 * Performs the close operation on a socket instance
525 int psock_close(struct socket *psock);
531 * bind() gives the socket 'psock' the local address 'addr'. 'addr' is
533 * a socket." When a socket is created with socket, it exists in a name
537 * psock Socket structure of the socket to bind
550 * The socket is already bound to an address.
552 * psock is a descriptor for a file, not a socket.
558 struct sockaddr; /* Forward reference. See nuttx/include/sys/socket.h */
559 int psock_bind(struct socket *psock, const struct sockaddr *addr,
566 * To accept connections, a socket is first created with psock_socket(), a
573 * psock Reference to an internal, boound socket structure.
585 * Another socket is already listening on the same port.
587 * The socket is not of a type that supports the listen operation.
591 int psock_listen(FAR struct socket *psock, int backlog);
597 * The psock_accept function is used with connection-based socket types
600 * connected socket with mostly the same properties as 'sockfd', and
601 * allocates a new socket descriptor for the socket, which is returned. The
602 * newly created socket is no longer in the listening state. The original
603 * socket 'sockfd' is unaffected by this call. Per file descriptor flags
606 * The 'sockfd' argument is a socket descriptor that has been created with
607 * socket(), bound to a local address with bind(), and is listening for
615 * If no pending connections are present on the queue, and the socket is
617 * connection is present. If the socket is marked non-blocking and no
622 * psock Reference to the listening socket structure
625 * newsock Location to return the accepted socket information.
632 * The socket is marked non-blocking and no connections are present to
635 * The referenced socket is not of type SOCK_STREAM.
659 int psock_accept(FAR struct socket *psock, FAR struct sockaddr *addr,
660 FAR socklen_t *addrlen, FAR struct socket *newsock);
666 * connect() connects the socket referred to by the structure 'psock'
669 * determined by the address space of the socket 'psock'.
671 * If the socket 'psock' is of type SOCK_DGRAM then 'addr' is the address
673 * datagrams are received. If the socket is of type SOCK_STREAM or
674 * SOCK_SEQPACKET, this call attempts to make a connection to the socket
684 * psock Pointer to a socket structure initialized by psock_socket()
685 * addr Server address (form depends on type of socket)
694 * socket broadcast flag enabled or the connection request failed
705 * The socket is non-blocking and a previous connection attempt has
712 * The socket structure address is outside the user's address space.
714 * The socket is non-blocking and the connection cannot be completed
719 * The socket is already connected.
723 * The file descriptor is not associated with a socket.
732 int psock_connect(struct socket *psock, const struct sockaddr *addr,
739 * The psock_send() call may be used only when the socket is in a
746 * - I accepts the internal socket structure as an input rather than an
747 * task-specific socket descriptor.
753 * psock - An instance of the internal socket structure.
765 ssize_t psock_send(FAR struct socket *psock, const void *buf, size_t len,
772 * The nx_send() call may be used only when the socket is in a
784 * sockfd - Socket descriptor of the socket
803 * socket, the parameters to and 'tolen' are ignored (and the error EISCONN
805 * returned when the socket was not actually connected.
808 * psock A pointer to a NuttX-specific, internal socket structure
820 * The socket is marked non-blocking and the requested operation
827 * The socket is not connection-mode, and no peer address is set.
835 * The connection-mode socket was connected already but a recipient
839 * The socket type requires that message be sent atomically, and the
848 * The socket is not connected, and no target has been given.
850 * The argument s is not a socket.
852 * Some bit in the flags argument is inappropriate for the socket
855 * The local end has been shut down on a connection oriented socket.
861 ssize_t psock_sendto(struct socket *psock, const void *buf,
869 * psock_recvfrom() receives messages from a socket, and may be used to
870 * receive data on a socket whether or not it is connection-oriented.
876 * - I accepts the internal socket structure as an input rather than an
877 * task-specific socket descriptor.
880 * psock - A pointer to a NuttX-specific, internal socket structure
896 ssize_t psock_recvfrom(struct socket *psock, void *buf, size_t len,
900 /* recv using the underlying socket structure */
909 * nx_recvfrom() receives messages from a socket, and may be used to
910 * receive data on a socket whether or not it is connection-oriented.
918 * sockfd - Socket descriptor of socket
946 * 'option' argument for the socket specified by the 'psock' argument. If
953 * retrieve options at the socket level, specify the level argument as
956 * See <sys/socket.h> a complete list of values for the 'option' argument.
959 * psock Socket structure of the socket to query
970 * The specified option is invalid at the specified socket 'level' or the
971 * socket has been shutdown.
975 * The 'psock' argument does not refer to a socket.
982 int psock_getsockopt(struct socket *psock, int level, int option,
991 * pointed to by the 'value' argument for the socket on the 'psock'
995 * options at the socket level, specify the level argument as SOL_SOCKET.
997 * See <sys/socket.h> a complete list of values for the 'option' argument.
1000 * psock Socket structure of socket to operate on
1012 * timeout fields in the socket structure.
1014 * The specified option is invalid at the specified socket 'level' or the
1015 * socket has been shut down.
1017 * The socket is already connected, and a specified option cannot be set
1018 * while the socket is connected.
1022 * The 'sockfd' argument does not refer to a socket.
1033 int psock_setsockopt(struct socket *psock, int level, int option,
1041 * the specified socket, stores this address in the sockaddr structure
1048 * If the socket has not been bound to a local name, the value stored in
1052 * psock Socket structure of socket to operate on
1058 * of the socket, and the 'addrlen' argument points to the length of the
1062 * EBADF - The socket argument is not a valid file descriptor.
1063 * ENOTSOCK - The socket argument does not refer to a socket.
1064 * EOPNOTSUPP - The operation is not supported for this socket's protocol.
1065 * ENOTCONN - The socket is not connected or otherwise has not had the
1067 * EINVAL - The socket has been shut down.
1073 int psock_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr,
1081 * the specified socket, stores this address in the sockaddr structure
1088 * If the socket has not been bound to a local name, the value stored in
1092 * psock Socket structure of socket to operate on
1098 * of the socket, and the 'addrlen' argument points to the length of the
1102 * EBADF - The socket argument is not a valid file descriptor.
1103 * ENOTSOCK - The socket argument does not refer to a socket.
1104 * EOPNOTSUPP - The operation is not supported for this socket's protocol.
1105 * ENOTCONN - The socket is not connected or otherwise has not had the
1107 * EINVAL - The socket has been shut down.
1113 int psock_getpeername(FAR struct socket *psock, FAR struct sockaddr *addr,
1123 * psock A pointer to a NuttX-specific, internal socket structure
1132 * 'psock' is not a valid, connected socket structure.
1147 int psock_ioctl(FAR struct socket *psock, int cmd, unsigned long arg);
1165 * 'sockfd' is not a valid socket descriptor.
1186 * The standard poll() operation redirects operations on socket descriptors
1190 * psock - An instance of the internal socket structure.
1202 int psock_poll(struct socket *psock, struct pollfd *fds, bool setup);
1208 * The standard poll() operation redirects operations on socket descriptors
1212 * fd - The socket descriptor of interest
1230 * Clone a socket descriptor to an arbitray descriptor number. If file
1232 * of socket file descriptors. If file descriptors are not implemented,
1241 int psock_dupsd(FAR struct socket *psock, int minsd);
1247 * Clone a socket descriptor to an arbitray descriptor number. If file
1249 * of socket file descriptors. If file descriptors are not implemented,
1264 * Clone a socket descriptor to an arbitray descriptor number. If file
1266 * of socket file descriptors. If file descriptors are not implemented,
1281 * Performs fstat operations on socket
1284 * sockfd - Socket descriptor of the socket to operate on
1305 int net_clone(struct socket *psock1, struct socket *psock2);
1311 * The send() call may be used only when the socket is in a connected state
1318 * psock An instance of the internal socket structure.
1328 * The socket is marked non-blocking and the requested operation
1335 * The socket is not connection-mode, and no peer address is set.
1343 * The connection-mode socket was connected already but a recipient
1347 * The socket type requires that message be sent atomically, and the
1356 * The socket is not connected, and no target has been given.
1358 * The argument s is not a socket.
1360 * Some bit in the flags argument is inappropriate for the socket
1363 * The local end has been shut down on a connection oriented socket.
1379 * Performs fcntl operations on socket
1382 * psock - An instance of the internal socket structure.
1392 int psock_vfcntl(FAR struct socket *psock, int cmd, va_list ap);
1399 * struct socket instance instead of a file descriptor.
1402 * psock - An instance of the internal socket structure.
1413 int psock_fcntl(FAR struct socket *psock, int cmd, ...);
1419 * Performs fcntl operations on socket
1422 * sockfd - Socket descriptor of the socket to operate on