---
title: "STM32+W5500 server에서 ping은 되는데, listen이 안됩니다."
url: "https://maker.wiznet.io/forum/15241"
markdown_url: "https://maker.wiznet.io/forum/15241/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "loopy th kim"
created: "2024-06-24T02:50:03+09:00"
last_activity: "2024-06-24T03:43:47+09:00"
language: "en"
views: 70
replies: 1
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# STM32+W5500 server에서 ping은 되는데, listen이 안됩니다.

## Question

Asked by loopy th kim on 2024-06-24 in Ethernet Chips.

stm32f407 와 W5500 lite 모듈을 사용하고 있습니다.

![](https://github.githubassets.com/favicons/favicon.svg) [github.com](https://github.com/KnowingBat/Ethernet-SPI/tree/master)

### [GitHub - KnowingBat/Ethernet-SPI: Simple TCP/IP loopback echo implementation...](https://github.com/KnowingBat/Ethernet-SPI/tree/master)

[master](https://github.com/KnowingBat/Ethernet-SPI/tree/master)

Simple TCP/IP loopback echo implementation using W5500 on STM32 - KnowingBat/Ethernet-SPI

이 깃허브의 소스를 기반으로 프로그램을 했는데,
main.c 의 mySocket = socket(1, Sn_MR_TCP, 502, 0); 이부분에서 안넘어옵니다.

그래서

![](https://avatars.discourse-cdn.com/v4/letter/c/9d8465/48.png) [W5500 stuck on Socket Close Function - while( getSn_CR(sn) )](https://forum.wiznet.io/t/topic/12350/23?page=2) [W5500](https://maker.wiznet.io/c/tcp-ip-chip/w5500/18)

> I found the solution, but another problem arose and I fixed it too. The problem is that the recv function returns an incorrect value. I could receive as much data as I wanted, but the received data was incorrect. A similar problem exists in the recv function. For this, editing the WIZCHIP_READ function is not enough. Because the recv function uses the WIZCHIP_READ_BUF function instead of WIZCHIP_READ. By editing this, the other problem was also solved. The whole solution was as follows. uint8_…

를 참조하여
w5500.c 파일의
uint8_t WIZCHIP_READ(uint32_t AddrSel) 함수에
WIZCHIP.IF.SPI._write_byte(0); 를 if else 다음에 추가하니 다음으로 넘어는 갑니다.

하지만 외부에서 PING은 되나 접속을 못합니다.

초기화, 리슨부분에서
err_t = listen(mySocket);
err_t가 0 이 아니라 -5가 넘어옵니다.
-5는 Invalid socket mode for socket operation 입니다.

PING은 외부에서 되는데… 어떻게해야할지 모르겠습니다.

답변좁 부탁드려요. 고맙습니다.

## Replies

### Reply 1 by loopy th kim, 2024-06-24

해결되었습니다.
실험용으로 달아놓은 lite보드와 열결되는 int / cs / rst 풀업모두 제거.
WIZCHIP.IF.SPI._write_byte(0); 다시 제거. 원래대로 복귀.
하니 err_t = listen(mySocket); 의 err_t 의 값이 1로 리턴되면서
정상작동됩니다.

![](https://github.githubassets.com/favicons/favicon.svg) [github.com](https://github.com/KnowingBat/Ethernet-SPI/tree/master)

### [GitHub - KnowingBat/Ethernet-SPI: Simple TCP/IP loopback echo implementation...](https://github.com/KnowingBat/Ethernet-SPI/tree/master)

[master](https://github.com/KnowingBat/Ethernet-SPI/tree/master)

Simple TCP/IP loopback echo implementation using W5500 on STM32 - KnowingBat/Ethernet-SPI

이대로 하면됩니다.

---

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