summaryrefslogtreecommitdiff
path: root/nuttx/net/socket.c
diff options
context:
space:
mode:
Diffstat (limited to 'nuttx/net/socket.c')
-rw-r--r--nuttx/net/socket.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/nuttx/net/socket.c b/nuttx/net/socket.c
index ad3ef1e92..43d4645fd 100644
--- a/nuttx/net/socket.c
+++ b/nuttx/net/socket.c
@@ -135,10 +135,27 @@ int socket(int domain, int type, int protocol)
/* Save the protocol type */
psock->s_type = type;
+ psock->s_conn = NULL;
- /* Allocate a TCP connection structure */
+ /* Allocate the appropriate connection structure */
+
+ switch (type)
+ {
+ case SOCK_STREAM:
+ psock->s_conn = uip_tcpalloc();
+ break;
+
+#ifdef CONFIG_NET_UDP
+ case SOCK_DGRAM:
+ psock->s_conn = uip_udpalloc();
+ break;
+#endif
+ default:
+ break;
+ }
+
+ /* Did we succesfully allocate some kind of connection structure? */
- psock->s_conn = uip_tcpalloc();
if (!psock->s_conn)
{
/* Failed to reserve a connection structure */