---
title: "W5100 send SOCKERR_SOCKSTATUS after few success writes"
url: "https://maker.wiznet.io/forum/12340"
markdown_url: "https://maker.wiznet.io/forum/12340/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "Sachin Gole"
created: "2017-06-20T16:49:20+09:00"
last_activity: "2017-06-20T21:23:26+09:00"
language: "en"
views: 1184
replies: 9
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# W5100 send SOCKERR_SOCKSTATUS after few success writes

## Question

Asked by Sachin Gole on 2017-06-20 in Ethernet Chips.

Hi All,

I am using w5100 Ethernet shield with STM32L476 Nucleo board.
I have following flow which fails at 5th operation, Can anyone help in figuring out what could be wrong in my operation.

**1. Create Socket**
socketNumber = socket(0, Sn_MR_TCP, portNo, SF_TCP_NODELAY);
socket() created socket number = 0
socket create return val = 1

**2. Send data on Socket**
socket number = 0 & numBytesToWrite = 132
retValue = send(socketNumber, (uint8_t *)pBuffer, numBytesToWrite);
send retValue = 132

**3. Read data on Socket**
socket number = 0 & maxBytesToRead = 2048
retValue = recv(socket, (uint8_t *)pBuffer, maxBytesToRead);
read bytes retValue = 1950

**4. Send data on Socket**
socket number = 0 & numBytesToWrite = 267
retValue = send(socketNumber, (uint8_t *)pBuffer, numBytesToWrite);
send retValue = 267

**5. Send data on Socket**
socket number = 0 & numBytesToWrite = 6
retValue = send(socketNumber, (uint8_t *)pBuffer, numBytesToWrite);
send retValue = -7

#define SOCKERR_SOCKSTATUS (SOCK_ERROR - 7) ///&lt; Invalid socket status for socket operation.

What could be that it is returning SOCKERR_SOCKSTATUS error.

Best regards,
Sachin

## Replies

### Reply 1 by Eugeny, 2017-06-20

When error occurs please read Sn_SR register to identify which status socket is in.

### Reply 2 by Sachin Gole, 2017-06-20

Hi Eugeny,

Thanks for reply.

After write failure I tried to read Sn_SR register it gave following value.

1. Send data on Socket
   socket number = 0 & numBytesToWrite = 6
   retValue = send(socketNumber, (uint8_t *)pBuffer, numBytesToWrite);
   send retValue = -7

Sn_SR(socket) retValue = 1027

Best regards,
Sachin

### Reply 3 by Sachin Gole, 2017-06-20

Sorry for inconvenience.

Previously, I just gave you #define for Sn_SR(socket) As it is 0x403

Now I just checked
retValue = getSn_SR(socket);
retValue = 0

### Reply 4 by Eugeny, 2017-06-20 (in reply to reply 3)

So for some reason socket is being closed when you try to send more data.
I can only guess what is going on; for example, if you use HTTP protocol, you may be sending wrong data during your step 4, and remote host closes the connection.
I propose you looking at what is going on the network using Wireshark to see what is actually being sent, and check the sequence of packets.
If you wish you can capture network activity log using Wireshark, and share it here so that we can have a look.

### Reply 5 by Sachin Gole, 2017-06-20

Thank you Eugeny for reply.

Finally I tried with local server on machine and send request from board and found that my processing take time so server timeout and close socket.

I have increased server read timeout and it worked. I need to process my data ASAP so server will not give timeout.

By the way I have not found blocking flag for 5100 while creating socket.

How to implement blocking send or connect request.

### Reply 6 by Eugeny, 2017-06-20

![](https://avatars.discourse-cdn.com/v4/letter/s/9f8e36/48.png) Sachin_Gole:

> By the way I have not found blocking flag for 5100 while creating socket.
>
> How to implement blocking send or connect request.

Please explain. What you want to achieve?

### Reply 7 by Sachin Gole, 2017-06-20

Currently I don’t have any blocker, as my application has lot of transaction with multiple socket on server so I was thinking to have each transaction in blocking mode which can confirm each operation done synchronously.

I can see that other chips like 5500 has flag SF_IPv6_BLOCK so thought if needed to 5100 then how I can implement same.

### Reply 8 by Eugeny, 2017-06-20

What is “blocking mode” in your understanding? Please explain what you want to achieve (not how you think you can achieve something).

### Reply 9 by Sachin Gole, 2017-06-20

synchronous write/read for large data in range of 20KB.

---

Source: https://maker.wiznet.io/forum/12340
