diff --git a/software/lwip/lwip/src/api/sockets.c b/software/lwip/lwip/src/api/sockets.c
index 359919e..9df78a4 100644
--- a/software/lwip/lwip/src/api/sockets.c
+++ b/software/lwip/lwip/src/api/sockets.c
@@ -2107,13 +2107,15 @@ lwip_setsockopt_internal(void *arg)
     case SO_REUSEPORT:
 #endif /* SO_REUSE */
     /* UNIMPL case SO_USELOOPBACK: */
-      if (*(int*)optval) {
-        ip_set_option(sock->conn->pcb.ip, optname);
-      } else {
-        ip_reset_option(sock->conn->pcb.ip, optname);
-      }
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, SOL_SOCKET, optname=0x%x, ..) -> %s\n",
-                  s, optname, (*(int*)optval?"on":"off")));
+			if (sock->conn->pcb.ip) {
+				if (*(int*)optval) {
+					ip_set_option(sock->conn->pcb.ip, optname);
+				} else {
+					ip_reset_option(sock->conn->pcb.ip, optname);
+				}
+				LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, SOL_SOCKET, optname=0x%x, ..) -> %s\n",
+										s, optname, (*(int*)optval?"on":"off")));
+			}
       break;
 #if LWIP_SO_SNDTIMEO
     case SO_SNDTIMEO:
@@ -2132,10 +2134,12 @@ lwip_setsockopt_internal(void *arg)
 #endif /* LWIP_SO_RCVBUF */
 #if LWIP_UDP
     case SO_NO_CHECK:
-      if (*(int*)optval) {
-        udp_setflags(sock->conn->pcb.udp, udp_flags(sock->conn->pcb.udp) | UDP_FLAGS_NOCHKSUM);
-      } else {
-        udp_setflags(sock->conn->pcb.udp, udp_flags(sock->conn->pcb.udp) & ~UDP_FLAGS_NOCHKSUM);
+			if (sock->conn->pcb.udp) {
+				if (*(int*)optval) {
+					udp_setflags(sock->conn->pcb.udp, udp_flags(sock->conn->pcb.udp) | UDP_FLAGS_NOCHKSUM);
+				} else {
+					udp_setflags(sock->conn->pcb.udp, udp_flags(sock->conn->pcb.udp) & ~UDP_FLAGS_NOCHKSUM);
+				}
       }
       break;
 #endif /* LWIP_UDP */
@@ -2149,27 +2153,35 @@ lwip_setsockopt_internal(void *arg)
   case IPPROTO_IP:
     switch (optname) {
     case IP_TTL:
-      sock->conn->pcb.ip->ttl = (u8_t)(*(int*)optval);
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_IP, IP_TTL, ..) -> %d\n",
-                  s, sock->conn->pcb.ip->ttl));
+			if (sock->conn->pcb.ip) {
+				sock->conn->pcb.ip->ttl = (u8_t)(*(int*)optval);
+				LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_IP, IP_TTL, ..) -> %d\n",
+										s, sock->conn->pcb.ip->ttl));
+			}
       break;
     case IP_TOS:
-      sock->conn->pcb.ip->tos = (u8_t)(*(int*)optval);
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_IP, IP_TOS, ..)-> %d\n",
-                  s, sock->conn->pcb.ip->tos));
+			if (sock->conn->pcb.ip) {
+				sock->conn->pcb.ip->tos = (u8_t)(*(int*)optval);
+				LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_IP, IP_TOS, ..)-> %d\n",
+										s, sock->conn->pcb.ip->tos));
+			}
       break;
 #if LWIP_IGMP
     case IP_MULTICAST_TTL:
-      sock->conn->pcb.udp->ttl = (u8_t)(*(u8_t*)optval);
+			if (sock->conn->pcb.udp)
+      	sock->conn->pcb.udp->ttl = (u8_t)(*(u8_t*)optval);
       break;
     case IP_MULTICAST_IF:
-      inet_addr_to_ipaddr(&sock->conn->pcb.udp->multicast_ip, (struct in_addr*)optval);
+			if (sock->conn->pcb.udp)
+      	inet_addr_to_ipaddr(&sock->conn->pcb.udp->multicast_ip, (struct in_addr*)optval);
       break;
     case IP_MULTICAST_LOOP:
-      if (*(u8_t*)optval) {
-        udp_setflags(sock->conn->pcb.udp, udp_flags(sock->conn->pcb.udp) | UDP_FLAGS_MULTICAST_LOOP);
-      } else {
-        udp_setflags(sock->conn->pcb.udp, udp_flags(sock->conn->pcb.udp) & ~UDP_FLAGS_MULTICAST_LOOP);
+			if (sock->conn->pcb.udp) {
+				if (*(u8_t*)optval) {
+					udp_setflags(sock->conn->pcb.udp, udp_flags(sock->conn->pcb.udp) | UDP_FLAGS_MULTICAST_LOOP);
+				} else {
+					udp_setflags(sock->conn->pcb.udp, udp_flags(sock->conn->pcb.udp) & ~UDP_FLAGS_MULTICAST_LOOP);
+				}
       }
       break;
     case IP_ADD_MEMBERSHIP:
@@ -2203,35 +2215,45 @@ lwip_setsockopt_internal(void *arg)
   case IPPROTO_TCP:
     switch (optname) {
     case TCP_NODELAY:
-      if (*(int*)optval) {
-        tcp_nagle_disable(sock->conn->pcb.tcp);
-      } else {
-        tcp_nagle_enable(sock->conn->pcb.tcp);
-      }
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_TCP, TCP_NODELAY) -> %s\n",
-                  s, (*(int *)optval)?"on":"off") );
+			if (sock->conn->pcb.tcp) {
+				if (*(int*)optval) {
+					tcp_nagle_disable(sock->conn->pcb.tcp);
+				} else {
+					tcp_nagle_enable(sock->conn->pcb.tcp);
+				}
+				LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_TCP, TCP_NODELAY) -> %s\n",
+										s, (*(int *)optval)?"on":"off") );
+			}
       break;
     case TCP_KEEPALIVE:
-      sock->conn->pcb.tcp->keep_idle = (u32_t)(*(int*)optval);
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_TCP, TCP_KEEPALIVE) -> %"U32_F"\n",
-                  s, sock->conn->pcb.tcp->keep_idle));
+			if (sock->conn->pcb.tcp) {
+				sock->conn->pcb.tcp->keep_idle = (u32_t)(*(int*)optval);
+				LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_TCP, TCP_KEEPALIVE) -> %"U32_F"\n",
+										s, sock->conn->pcb.tcp->keep_idle));
+			}
       break;
 
 #if LWIP_TCP_KEEPALIVE
     case TCP_KEEPIDLE:
-      sock->conn->pcb.tcp->keep_idle = 1000*(u32_t)(*(int*)optval);
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_TCP, TCP_KEEPIDLE) -> %"U32_F"\n",
-                  s, sock->conn->pcb.tcp->keep_idle));
+			if (sock->conn->pcb.tcp) {
+				sock->conn->pcb.tcp->keep_idle = 1000*(u32_t)(*(int*)optval);
+				LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_TCP, TCP_KEEPIDLE) -> %"U32_F"\n",
+										s, sock->conn->pcb.tcp->keep_idle));
+			}
       break;
     case TCP_KEEPINTVL:
-      sock->conn->pcb.tcp->keep_intvl = 1000*(u32_t)(*(int*)optval);
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_TCP, TCP_KEEPINTVL) -> %"U32_F"\n",
-                  s, sock->conn->pcb.tcp->keep_intvl));
+			if (sock->conn->pcb.tcp) {
+				sock->conn->pcb.tcp->keep_intvl = 1000*(u32_t)(*(int*)optval);
+				LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_TCP, TCP_KEEPINTVL) -> %"U32_F"\n",
+										s, sock->conn->pcb.tcp->keep_intvl));
+			}
       break;
     case TCP_KEEPCNT:
-      sock->conn->pcb.tcp->keep_cnt = (u32_t)(*(int*)optval);
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_TCP, TCP_KEEPCNT) -> %"U32_F"\n",
-                  s, sock->conn->pcb.tcp->keep_cnt));
+			if (sock->conn->pcb.tcp) {
+				sock->conn->pcb.tcp->keep_cnt = (u32_t)(*(int*)optval);
+				LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_TCP, TCP_KEEPCNT) -> %"U32_F"\n",
+										s, sock->conn->pcb.tcp->keep_cnt));
+			}
       break;
 #endif /* LWIP_TCP_KEEPALIVE */
     default:
@@ -2245,24 +2267,28 @@ lwip_setsockopt_internal(void *arg)
   case IPPROTO_UDPLITE:
     switch (optname) {
     case UDPLITE_SEND_CSCOV:
-      if ((*(int*)optval != 0) && ((*(int*)optval < 8) || (*(int*)optval > 0xffff))) {
-        /* don't allow illegal values! */
-        sock->conn->pcb.udp->chksum_len_tx = 8;
-      } else {
-        sock->conn->pcb.udp->chksum_len_tx = (u16_t)*(int*)optval;
-      }
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_UDPLITE, UDPLITE_SEND_CSCOV) -> %d\n",
-                  s, (*(int*)optval)) );
+			if (sock->conn->pcb.udp) {
+				if ((*(int*)optval != 0) && ((*(int*)optval < 8) || (*(int*)optval > 0xffff))) {
+					/* don't allow illegal values! */
+					sock->conn->pcb.udp->chksum_len_tx = 8;
+				} else {
+					sock->conn->pcb.udp->chksum_len_tx = (u16_t)*(int*)optval;
+				}
+				LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_UDPLITE, UDPLITE_SEND_CSCOV) -> %d\n",
+										s, (*(int*)optval)) );
+			}
       break;
     case UDPLITE_RECV_CSCOV:
-      if ((*(int*)optval != 0) && ((*(int*)optval < 8) || (*(int*)optval > 0xffff))) {
-        /* don't allow illegal values! */
-        sock->conn->pcb.udp->chksum_len_rx = 8;
-      } else {
-        sock->conn->pcb.udp->chksum_len_rx = (u16_t)*(int*)optval;
-      }
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_UDPLITE, UDPLITE_RECV_CSCOV) -> %d\n",
-                  s, (*(int*)optval)) );
+			if (sock->conn->pcb.udp) {
+				if ((*(int*)optval != 0) && ((*(int*)optval < 8) || (*(int*)optval > 0xffff))) {
+					/* don't allow illegal values! */
+					sock->conn->pcb.udp->chksum_len_rx = 8;
+				} else {
+					sock->conn->pcb.udp->chksum_len_rx = (u16_t)*(int*)optval;
+				}
+				LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_UDPLITE, UDPLITE_RECV_CSCOV) -> %d\n",
+										s, (*(int*)optval)) );
+			}
       break;
     default:
       LWIP_ASSERT("unhandled optname", 0);
