---
title: "Socket.c bugs"
url: "https://maker.wiznet.io/forum/10507"
markdown_url: "https://maker.wiznet.io/forum/10507/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "kammutierspule"
created: "2014-09-10T19:57:27+09:00"
last_activity: "2017-05-04T08:34:11+09:00"
language: "en"
views: 1077
replies: 5
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# Socket.c bugs

## Question

Asked by kammutierspule on 2014-09-10 in Ethernet Chips.

I found two issues so far with socket.c source code

my file version is: &lt;2014/05/01> V1.0.3. Refer to M20140501

sock_io_mode issue: I was expecting that this flag be cleaned when you close the socket.

The other issue is related with recv
In block io mode, it doesn’t return until data reception is completed - data is filled as *len* in socket buffer.

but what is implemented is that it will return as soon as it get any data:
if(recvsize != 0) break;
I think this code need review.

## Replies

### Reply 1 by kammutierspule, 2014-09-11

I was looking for BSD recv function and It looks that your implementation is correct:

[linux.die.net/man/2/recv](http://linux.die.net/man/2/recv)
“The receive calls normally return any data available, up to the requested amount, rather than waiting for receipt of the full amount requested.”

So the issue is in the wiznet socket.h documentation:

[quote]
It waits for data as much as the application wants to receive.
…
In block io mode, it doesn’t return until data reception is completed - data is filled as *len* in socket buffer.[/quote]

So, it no correct to say “data is filled as len in socket buffer”

### Reply 2 by alexpescaru, 2014-09-14

And I believe there is one more thing to correct in socket.c, function sendto().
Bellow, I believe should be taddr, not addr.
Am I right?

---

//M20140501 : For avoiding fatal error on memory align mismatched
//if(*((uint32_t*)addr) == 0) return SOCKERR_IPINVALID;
{
uint32_t taddr;
taddr = ((uint32_t)addr[0]) & 0x000000FF;
taddr = (taddr &lt;&lt; 8) + ((uint32_t)addr[1] & 0x000000FF);
taddr = (taddr &lt;&lt; 8) + ((uint32_t)addr[2] & 0x000000FF);
taddr = (taddr &lt;&lt; 8) + ((uint32_t)addr[3] & 0x000000FF);
}
//
if(*((uint32_t*)[color=#FF0000]addr[/color]) == 0) return SOCKERR_IPINVALID;

---

### Reply 3 by kammutierspule, 2014-09-16

Wouldn’t it be better if this ioLibrary_BSD was in a public repository (github wiznet account?) so we all can use the appropriated tools and platform for bug reporting, version control… etc?!

### Reply 4 by fherbert, 2014-10-14

I’ve just checked the current version (1.0.3) of code for socket.c at [url][https://github.com/Wiznet/W5500_EVB\[/url\]](https://github.com/Wiznet/W5500_EVB%5B/url%5D) or [url][http://wizwiki.net/wiki/doku.php?id=products:w5500:driver\[/url\]](http://wizwiki.net/wiki/doku.php?id=products:w5500:driver%5B/url%5D) and the fixes don’t appear to have made it to this driver yet. When will this driver be updated at github?

### Reply 5 by hjjeon0608, 2014-10-27

Hi, fherbert

We are modifying code about your point and other points.
So, we will update next version ASAP!

Plz, wait a while kindly~:D

---

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