From 622ac27bfa6f4fd1c4d1b82a911978078bfd621d Mon Sep 17 00:00:00 2001 From: patacongo Date: Mon, 30 Jan 2012 21:29:59 +0000 Subject: Add new psock layer; telnet session is now wrapped in a character device git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4347 7fd9a85b-ad96-42d3-883c-3090e2eb8679 --- nuttx/net/send.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 74 insertions(+), 6 deletions(-) (limited to 'nuttx/net/send.c') diff --git a/nuttx/net/send.c b/nuttx/net/send.c index 4eceddffc..087b43351 100644 --- a/nuttx/net/send.c +++ b/nuttx/net/send.c @@ -1,8 +1,8 @@ /**************************************************************************** * net/send.c * - * Copyright (C) 2007-2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2007-2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -336,7 +336,7 @@ end_wait: ****************************************************************************/ /**************************************************************************** - * Function: send + * Function: psock_send * * Description: * The send() call may be used only when the socket is in a connected state @@ -346,7 +346,7 @@ end_wait: * equivalent to sendto(sockfd,buf,len,flags,NULL,0). * * Parameters: - * sockfd Socket descriptor of socket + * psock And instance of the internal socket structure. * buf Data to send * len Length of data to send * flags Send flags @@ -399,9 +399,8 @@ end_wait: * ****************************************************************************/ -ssize_t send(int sockfd, const void *buf, size_t len, int flags) +ssize_t psock_send(FAR struct socket *psock, const void *buf, size_t len, int flags) { - FAR struct socket *psock = sockfd_socket(sockfd); struct send_s state; uip_lock_t save; int err; @@ -525,4 +524,73 @@ errout: return ERROR; } +/**************************************************************************** + * Function: send + * + * Description: + * The send() call may be used only when the socket is in a connected state + * (so that the intended recipient is known). The only difference between + * send() and write() is the presence of flags. With zero flags parameter, + * send() is equivalent to write(). Also, send(sockfd,buf,len,flags) is + * equivalent to sendto(sockfd,buf,len,flags,NULL,0). + * + * Parameters: + * sockfd Socket descriptor of socket + * buf Data to send + * len Length of data to send + * flags Send flags + * + * Returned Value: + * On success, returns the number of characters sent. On error, + * -1 is returned, and errno is set appropriately: + * + * EAGAIN or EWOULDBLOCK + * The socket is marked non-blocking and the requested operation + * would block. + * EBADF + * An invalid descriptor was specified. + * ECONNRESET + * Connection reset by peer. + * EDESTADDRREQ + * The socket is not connection-mode, and no peer address is set. + * EFAULT + * An invalid user space address was specified for a parameter. + * EINTR + * A signal occurred before any data was transmitted. + * EINVAL + * Invalid argument passed. + * EISCONN + * The connection-mode socket was connected already but a recipient + * was specified. (Now either this error is returned, or the recipient + * specification is ignored.) + * EMSGSIZE + * The socket type requires that message be sent atomically, and the + * size of the message to be sent made this impossible. + * ENOBUFS + * The output queue for a network interface was full. This generally + * indicates that the interface has stopped sending, but may be + * caused by transient congestion. + * ENOMEM + * No memory available. + * ENOTCONN + * The socket is not connected, and no target has been given. + * ENOTSOCK + * The argument s is not a socket. + * EOPNOTSUPP + * Some bit in the flags argument is inappropriate for the socket + * type. + * EPIPE + * The local end has been shut down on a connection oriented socket. + * In this case the process will also receive a SIGPIPE unless + * MSG_NOSIGNAL is set. + * + * Assumptions: + * + ****************************************************************************/ + +ssize_t send(int sockfd, const void *buf, size_t len, int flags) +{ + return psock_send(sockfd_socket(sockfd), buf, len, flags); +} + #endif /* CONFIG_NET && CONFIG_NET_TCP */ -- cgit v1.2.3