# WP7607-1 with Legato 21.05, tcp-server not working as expected

**URL:** <https://forum.legato.io/t/wp7607-1-with-legato-21-05-tcp-server-not-working-as-expected/6881>\
**Category:** Uncategorized\
**Created:** [January 22, 2025, 10:50am UTC](https://forum.legato.io/t/wp7607-1-with-legato-21-05-tcp-server-not-working-as-expected/6881 "2025-01-22T10:50:39Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![buepawe](https://avatars.discourse-cdn.com/v4/letter/b/d78d45/32.png) [@buepawe](https://forum.legato.io/u/buepawe)\
**Post date:** [January 22, 2025, 10:50am UTC](https://forum.legato.io/t/wp7607-1-with-legato-21-05-tcp-server-not-working-as-expected/6881/1 "2025-01-22T10:50:39Z")

</div>

I have an old legato app running fine with legato 19.2 and yocto 3.18. Now with new generations of wp7607-1 modules I have to use legato 21.05 and linux 4.14. I was able to compile and install yocto with additional progs (openvpn) as I did with last version of legato dist-source (version 02.37.10.02). I was also able to run mksys which also included my app. The app leaved unchanged therefor.

One function of my app is a tcp-server. It ran without problems with modules using linux 3.18 and legato 19.2. Now the app starts as expected and does not show any error in logread but I can’t connect to the server anymore. I have a running openvpn-connection and I am able to ping to the device. I am also able to create a socat-tcp-server for a test and can connect to it but my app’s tcpserver is not usefull anymore.

I can see the server listening with netstat -a  
tcp 0 0 0.0.0.0:xxxx 0.0.0.0:\* LISTEN

It is no problem of firewall. The server is also not working with localhost or with all ports opened (iptables -A INPUT -j ACCEPT).

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [January 22, 2025, 10:58am UTC](https://forum.legato.io/t/wp7607-1-with-legato-21-05-tcp-server-not-working-as-expected/6881/2 "2025-01-22T10:58:28Z")

</div>

So is this related to particule port number as you said that you can create another tcp server port?

Did you capture wireshark log for investigation?

Does this help?

> [@TCP communication between apps](https://forum.legato.io/t/tcp-communication-between-apps/4736/2):
>
> Do you mean you don’t want to use IPC to have communication between two applications? With the application in below link to set up TCP server, I can communicate with other application like “nc 127.0.0.1 5000”

---

<div class="post-metadata">

**Author:** ![buepawe](https://avatars.discourse-cdn.com/v4/letter/b/d78d45/32.png) [@buepawe](https://forum.legato.io/u/buepawe)\
**Post date:** [January 22, 2025, 11:02am UTC](https://forum.legato.io/t/wp7607-1-with-legato-21-05-tcp-server-not-working-as-expected/6881/3 "2025-01-22T11:02:23Z")

</div>

Hello,

No it is not related to a specific port number. It seems to be a problem with my new compiled app with current legato and / or linux 4.14.

I thought it could be a sandbox-problem but the app is currently not sandboxed.

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [January 22, 2025, 11:03am UTC](https://forum.legato.io/t/wp7607-1-with-legato-21-05-tcp-server-not-working-as-expected/6881/4 "2025-01-22T11:03:17Z")

</div>

Did you capture wireshark log for investigation?

Does this application help?

> [@Networking: TCP server Operation not permitted (errno -1)](https://forum.legato.io/t/networking-tcp-server-operation-not-permitted-errno-1/4650/4):
>
> You can use my TCP echo server application which uses read() instead of recv(). Procedure: compile and download attached application iptables -I INPUT -j ACCEPT app start fwupdateDownloader in Linux PC, type “nc 192.168.2.2 5000” after connected, you can type some characters and the application will echo back to linux PC. [fwupdateDownloader.rar](https://forum.legato.io/uploads/short-url/rtNMsZzuYC3CC0QmrsWh0EfadIR.rar) (174.0 KB)

---

<div class="post-metadata">

**Author:** ![buepawe](https://avatars.discourse-cdn.com/v4/letter/b/d78d45/32.png) [@buepawe](https://forum.legato.io/u/buepawe)\
**Post date:** [January 22, 2025, 11:23am UTC](https://forum.legato.io/t/wp7607-1-with-legato-21-05-tcp-server-not-working-as-expected/6881/5 "2025-01-22T11:23:23Z")

</div>

Hello,

I will add tcpdump to my system and try to capture packets.

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [January 22, 2025, 11:26am UTC](https://forum.legato.io/t/wp7607-1-with-legato-21-05-tcp-server-not-working-as-expected/6881/6 "2025-01-22T11:26:20Z")

</div>

You can also capture wireshark log on PC side

Btw, you can also try this app

> [@Networking: TCP server Operation not permitted (errno -1)](https://forum.legato.io/t/networking-tcp-server-operation-not-permitted-errno-1/4650/4):
>
> You can use my TCP echo server application which uses read() instead of recv(). Procedure: compile and download attached application iptables -I INPUT -j ACCEPT app start fwupdateDownloader in Linux PC, type “nc 192.168.2.2 5000” after connected, you can type some characters and the application will echo back to linux PC. [fwupdateDownloader.rar](https://forum.legato.io/uploads/short-url/rtNMsZzuYC3CC0QmrsWh0EfadIR.rar) (174.0 KB)

---

<div class="post-metadata">

**Author:** ![buepawe](https://avatars.discourse-cdn.com/v4/letter/b/d78d45/32.png) [@buepawe](https://forum.legato.io/u/buepawe)\
**Post date:** [January 22, 2025, 11:28am UTC](https://forum.legato.io/t/wp7607-1-with-legato-21-05-tcp-server-not-working-as-expected/6881/7 "2025-01-22T11:28:54Z")

</div>

With my older Wp7607-1 everything works fine. Also a server created with socat is responding. The tcp-server of my app does not even recognize a connection!

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [January 22, 2025, 11:31am UTC](https://forum.legato.io/t/wp7607-1-with-legato-21-05-tcp-server-not-working-as-expected/6881/8 "2025-01-22T11:31:53Z")

</div>

If the app above works, then you can port the app to your application

---

<div class="post-metadata">

**Author:** ![buepawe](https://avatars.discourse-cdn.com/v4/letter/b/d78d45/32.png) [@buepawe](https://forum.legato.io/u/buepawe)\
**Post date:** [January 22, 2025, 11:54am UTC](https://forum.legato.io/t/wp7607-1-with-legato-21-05-tcp-server-not-working-as-expected/6881/9 "2025-01-22T11:54:32Z")

</div>

I started my apps tcpserver on port 9302 (and it is running):

root 2417 0.0 0.7 3196 1216 pts/0 S 12:37 0:00 ./tcpserver -p 9302 -t 900 start

I connected to a PC and used the local ecm0-interface for testing. I started socat with:

socat -v -d -d TCP-LISTEN:9302,fork TCP:localhost:9300

and opened firewall with:

iptables -A INPUT -j ACCEPT

On pc-side I startet

echo “bla” | nc 192.168.2.2 9300

socat told me:

2025/01/22 12:47:26 socat[3314] N listening on AF=2 0.0.0.0:9300  
2025/01/22 12:47:33 socat[3314] N accepting connection from AF=2 192.168.2.3:50126 on AF=2 192.168.2.2:9300  
2025/01/22 12:47:33 socat[3314] N forked off child process 3322  
2025/01/22 12:47:33 socat[3314] N listening on AF=2 0.0.0.0:9300  
2025/01/22 12:47:33 socat[3322] N opening connection to AF=2 127.0.0.1:9302  
2025/01/22 12:49:42 socat[3322] E connect(5, AF=2 127.0.0.1:9302, 16): Connection timed out  
2025/01/22 12:49:42 socat[3322] N exit(1)  
2025/01/22 12:49:42 socat[3314] N childdied(): handling signal 17

loread tells me:

Jan 22 12:33:57 swi-mdm9x28-wp user.info Legato: INFO | tcpserver[2107]/tcpServer T=main | tcpserver.c \_tcpServer\_COMPONENT\_INIT() 375 | TCP-Server  
Jan 22 12:35:05 swi-mdm9x28-wp user.info Legato: INFO | tcpserver[2201]/tcpServer T=main | tcpserver.c \_tcpServer\_COMPONENT\_INIT() 375 | TCP-Server  
Jan 22 12:36:46 swi-mdm9x28-wp user.warn Legato: -WRN- | configTree[1238]/framework T=main | safeRef.c le\_ref\_CreateRef() 546 | Safe reference map maximum exceeded for refPathIteratorMap, new size 42  
Jan 22 12:37:10 swi-mdm9x28-wp user.info Legato: INFO | tcpserver[2387]/tcpServer T=main | tcpserver.c \_tcpServer\_COMPONENT\_INIT() 375 | TCP-Server  
Jan 22 12:37:25 swi-mdm9x28-wp user.info Legato: INFO | tcpserver[2402]/tcpServer T=main | tcpserver.c \_tcpServer\_COMPONENT\_INIT() 375 | TCP-Server  
Jan 22 12:37:25 swi-mdm9x28-wp user.info Legato: INFO | tcpserver[2402]/tcpServer T=main | tcpserver.c Command() 329 | start server  
Jan 22 12:37:25 swi-mdm9x28-wp user.info Legato: INFO | tcpserver[2402]/tcpServer T=main | tcpserver.c Command() 343 | Starte Server  
Jan 22 12:37:25 swi-mdm9x28-wp user.info Legato: INFO | tcpserver[2402]/tcpServer T=main | tcpserver.c Command() 365 | TCP-Server is monitoring port 9302  
Jan 22 12:37:31 swi-mdm9x28-wp user.info Legato: INFO | tcpserver[2417]/tcpServer T=main | tcpserver.c \_tcpServer\_COMPONENT\_INIT() 375 | TCP-Server  
Jan 22 12:37:31 swi-mdm9x28-wp user.info Legato: INFO | tcpserver[2417]/tcpServer T=main | tcpserver.c Command() 329 | start server  
Jan 22 12:37:31 swi-mdm9x28-wp user.info Legato: INFO | tcpserver[2417]/tcpServer T=main | tcpserver.c Command() 343 | Starte Server  
Jan 22 12:37:31 swi-mdm9x28-wp user.info Legato: INFO | tcpserver[2417]/tcpServer T=main | tcpserver.c Command() 365 | TCP-Server is monitoring port 9302  
Jan 22 12:40:00 swi-mdm9x28-wp user.info kernel: [562.110601] device lo entered promiscuous mode  
Jan 22 12:41:40 swi-mdm9x28-wp user.info kernel: [662.442168] device lo left promiscuous mode  
Jan 22 12:42:24 swi-mdm9x28-wp user.info kernel: [706.100613] device lo entered promiscuous mode  
Jan 22 12:42:30 swi-mdm9x28-wp user.info kernel: [711.946706] TCP: request\_sock\_TCP: Possible SYN flooding on port 9302. Dropping request. Check SNMP counters.  
Jan 22 12:42:37 swi-mdm9x28-wp user.info kernel: [719.587200] device lo left promiscuous mode

---

<div class="post-metadata">

**Author:** ![buepawe](https://avatars.discourse-cdn.com/v4/letter/b/d78d45/32.png) [@buepawe](https://forum.legato.io/u/buepawe)\
**Post date:** [January 22, 2025, 12:09pm UTC](https://forum.legato.io/t/wp7607-1-with-legato-21-05-tcp-server-not-working-as-expected/6881/10 "2025-01-22T12:09:54Z")

</div>

I compiled and installed your app fwdownloader. It runs as expected. I can connect local with nc and see the echo of my messages.

---

<div class="post-metadata">

**Author:** ![buepawe](https://avatars.discourse-cdn.com/v4/letter/b/d78d45/32.png) [@buepawe](https://forum.legato.io/u/buepawe)\
**Post date:** [January 22, 2025, 12:48pm UTC](https://forum.legato.io/t/wp7607-1-with-legato-21-05-tcp-server-not-working-as-expected/6881/11 "2025-01-22T12:48:36Z")

</div>

Now i compared your server with mine:

I used  
socket(AF\_INET, SOCK\_STREAM, IPPROTO\_TCP)  
you use  
socket(AF\_INET, SOCK\_STREAM, 0)

I used  
if (listen(fd,0) \< 0) …  
you use  
if (listen(fd,1) \< 0) …

I changed the 2 lines. Additionally I had to remove the build-Directory to recompile all code. After that my server worked as expected.
