summaryrefslogtreecommitdiff
path: root/nuttx/net/sendto.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-09-09 19:47:52 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-09-09 19:47:52 +0000
commit029001d3f18801589c585b190fdc9655bec8e545 (patch)
tree880c7410b4fbcb43c2dd5cfce6618d4d5b0953e5 /nuttx/net/sendto.c
parent7a65f932826220c741ffbf5698b48692a787d915 (diff)
downloadnuttx-029001d3f18801589c585b190fdc9655bec8e545.tar.gz
nuttx-029001d3f18801589c585b190fdc9655bec8e545.tar.bz2
nuttx-029001d3f18801589c585b190fdc9655bec8e545.zip
Implment TCP recv()
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@340 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/net/sendto.c')
-rw-r--r--nuttx/net/sendto.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/nuttx/net/sendto.c b/nuttx/net/sendto.c
index bba9c5b47..b14f301a2 100644
--- a/nuttx/net/sendto.c
+++ b/nuttx/net/sendto.c
@@ -244,9 +244,26 @@ ssize_t sendto(int sockfd, const void *buf, size_t len, int flags,
udp_conn = (struct uip_udp_conn *)psock->s_conn;
udp_conn->private = (void*)&state;
udp_conn->callback = sendto_interrupt;
- irqrestore(save);
+
+ /* Enable the UDP socket */
+
+ uip_udpenable(psock->s_conn);
+
+ /* Wait for either the receive to complete or for an error/timeout to occur.
+ * NOTES: (1) sem_wait will also terminate if a signal is received, (2)
+ * interrupts are disabled! They will be re-enabled while the task sleeps
+ * and automatically re-enabled when the task restarts.
+ */
sem_wait(&state.st_sem);
+
+ /* Make sure that no further interrupts are processed */
+
+ uip_udpdisable(psock->s_conn);
+ udp_conn->private = NULL;
+ udp_conn->callback = NULL;
+ irqrestore(save);
+
sem_destroy(&state.st_sem);
/* Set the socket state to idle */