---
title: "About W5500 chip send()，recv() Date"
url: "https://maker.wiznet.io/forum/15065"
markdown_url: "https://maker.wiznet.io/forum/15065/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "Bohu-Tang"
created: "2023-11-13T06:31:19+09:00"
last_activity: "2023-11-16T06:07:17+09:00"
language: "en"
views: 257
replies: 6
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# About W5500 chip send()，recv() Date

## Question

Asked by Bohu-Tang on 2023-11-13 in Ethernet Chips.

Dear all
When I use the W5500 chip, I use the computer as the client (3) and the w5500 as the server (64). I divided buf into send_buf and recv_buf. When I used the network debugging assistant to send data, I found that the data in my recv() was the data I sent.That is, the data in recv_buf is correct. But the data in my send_buf is wrong, sometimes it is garbled.However, when I define buf in both send() and recv() to be the same buf. The data sent at this time is indeed correct. I would like to ask, must the buf of send() and recv() be defined as the same buf?
Looking forward to the official’s answer.

## Replies

### Reply 1 by Alan, 2023-11-13

No, it doesn’t have to be the same buffer. Maybe the declaration is wrong?

### Reply 2 by Bohu-Tang, 2023-11-14 (in reply to reply 1)

Hi,Alan
Thanks for your answer.The first picture below shows the function I wrote. In lines 22 and 23 I split buf into recv_buf and send_buf. Lines 60 and 61. I send the data using the send() and recv() functions, respectively.I use wireshark to capture network packets. Turns out the data I sent to the server was correct. But the data the server sent back to me was wrong.Look at the second picture, the third picture, and the fourth picture.

[![问题1](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/7/72809e865a0a656dadd5f90fe7d8102ad0668c29.png) 问题1693×1314 277 KB](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/7/72809e865a0a656dadd5f90fe7d8102ad0668c29.png)

[![问题2](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/4/4971f815f0d09d25c08e9fb37be57a11a47a99b9.png) 问题2562×720 33.8 KB](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/4/4971f815f0d09d25c08e9fb37be57a11a47a99b9.png)

[![问题3](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/c/c744111ba2ab3b6bc79a24fb0ca913aa973464f2.png) 问题31920×1030 72.6 KB](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/c/c744111ba2ab3b6bc79a24fb0ca913aa973464f2.png)

[![问题4](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/a/aeefeb9530a683e21bee82421f699b49abeb0f54.png) 问题41920×1030 73.2 KB](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/a/aeefeb9530a683e21bee82421f699b49abeb0f54.png)

I think it’s because the two BUFs are defined separately. I send data to the server, so recv_buf receives normal data. send_buf has no data, so the numbers in send_buf are random numbers. But I defined the initial value for send_buf as shown in the fifth figure. But using wireshark to look at the data, it is not the array {1,1,1,1} in this diagram.
![问题5](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/2/21c503ee984f4418b6e56644da38a7f107fc6c06.png)
What I need to do now is for recv_buf to receive the data and send_buf to send another set of data. I don’t know what to do. I would appreciate it if you could solve my confusion.look forward to your good news.

### Reply 3 by Bohu-Tang, 2023-11-14 (in reply to reply 1)

This is my send function and my receive function.I hope that will be helpful.

[![问题6](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/0/037bf9845aed36ce900167ded1dfbb8fd8b398b3.png) 问题6649×832 156 KB](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/0/037bf9845aed36ce900167ded1dfbb8fd8b398b3.png)

![问题7](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/4/413333ffe1c041f589579ab300973b923d8a657a.png)

### Reply 4 by Bohu-Tang, 2023-11-15

Looking forward to hearing from the staff.

### Reply 5 by louis, 2023-11-16 (in reply to reply 4)

hello.

Unfortunately, due to company policy, we are unable to support code reviews.
We apologize for the inconvenience, but we hope you’ll take a look at the Loopback example below and fix it.

[github.com](https://github.com/Wiznet/ioLibrary_Driver/blob/master/Application/loopback/loopback.c)

#### [Wiznet/ioLibrary_Driver/blob/master/Application/loopback/loopback.c](https://github.com/Wiznet/ioLibrary_Driver/blob/master/Application/loopback/loopback.c)

```
#include <stdio.h>
#include "loopback.h"
#include "socket.h"
#include "wizchip_conf.h"

#if LOOPBACK_MODE == LOOPBACK_MAIN_NOBLCOK

int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port)
{
   int32_t ret;
   uint16_t size = 0, sentsize=0;

#ifdef _LOOPBACK_DEBUG_
   uint8_t destip[4];
   uint16_t destport;
#endif

   switch(getSn_SR(sn))
   {
      case SOCK_ESTABLISHED :
```

This file has been truncated. [show original](https://github.com/Wiznet/ioLibrary_Driver/blob/master/Application/loopback/loopback.c)

### Reply 6 by Bohu-Tang, 2023-11-16

Thank you for your reply. I solved the problem yesterday.

---

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