FreeRTOS Plus TCP Minimal Windows Simulator SimpleUDPClientAndServer


I am testing simple UDP Client/server application.

I get this on console:

0 98 [IP-task] 
The following network interfaces are available:
Interface 1 - rpcap://\Device\NPF_{F13A9E5D-BAD9-4454-A630-B54F94B08672}
1 98 [IP-task]               (Network adapter 'Intel(R) PRO/1000 MT  síeové pYipojení' on local host)
2 98 [IP-task] Interface 2 - rpcap://\Device\NPF_{F142B748-A693-4964-9F66-B5F80DA00E81}
              (Network adapter 'Microsoft' on local host)
3 98 [IP-task] 
Attempting to open interface number 1.
4 2205 [IP-task] vDHCPProcess: offer
vDHCPProcess: offer
5 2306 [IP-task] 
IP Address:
Subnet Mask:
6 2307 [IP-task] Gateway Address:
DNS Server Address:

When enabled debug printing to UDP, I see traffic from which is address allocated by DHCP to this application to which is echo server in my case.

Especially line in server part

		lBytes = FreeRTOS_recvfrom( xListeningSocket, cReceivedString, sizeof( cReceivedString ), 0, &xClient, &xClientLength );

returns with -11 and subsequent assert fails. When commenting out assert, application continues but receive returns always -11.

Socket is properly opened without error.

Client send function returns number of bytes send always 51.

I don’t see any traffic from client to server task on port 5005 using Wireshark.
(tried also port 4500, same result)
tried with firewall switched off, tried with enabling app through firewall, tried enable port 5005.
disabled also zero copy client/server tasks.
disabled TCP tasks which also don’t work.

ping RTOSDemo from other PC works

what could be the problem? thanks


-11 means the operation would block, - which means there is no data to read. Do you have a read block time on the socket?

If I understand your post correctly it sounds like you have got network access because you have an IP address assigned from the DHCP server, and you can send because you are sending logging data through a different UDP socket, but you don’t have any network connectivity between the UDP client and server socket - is that correct?

Can you step into the sendto() function for the client to see what it does?

It is possible your network setup is just not going to let you send and receive on the same computer - I have heard that before also not experienced it myself. I have an alternative setup whereby I use a virtual Ethernet port that gets installed with VirtualBox instead of the real Ethernet port - that also works but requires different network setup - specifically the network interface to use changes and I need to configure a static IP address that is compatible with whichever IP address the virtual network has.

thanks for taking time to help me

  1. it is original example, so timeout for send receive are set I believe from FreeRTOSIPconfig.h

#define ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME ( 5000 )
#define ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME ( 5000 )

  1. yes, I dont have connectivity between client and server

  2. I tried different setups

a) first on my PC which has only WiFi, no success
b) on another PC with wired eth port, no luck
c) again on my PC but with virtual machine running Windows7, there I have bridge between virtual machine and real WiFi adapter

  1. npf WinPcap service is running

5 when I step into sendto(), I think it exits from here

/* Ask the IP-task to send this packet /
if( xSendEventStructToIPTask( &xStackTxEvent, xTicksToWait ) == pdPASS )
The packet was successfully sent to the IP task. */
lReturn = ( int32_t ) uxTotalDataLength;

returning number of bytes send

  1. if I step into

case eStackTxEvent:

/* The network stack has generated a packet to send. A

  • pointer to the generated buffer is located in the pvData
  • member of the received event structure. */
    vProcessGeneratedUDPPacket( ipCAST_PTR_TO_TYPE_PTR( NetworkBufferDescriptor_t, xReceivedEvent.pvData ) );

In most cases a demo using WInPCap can only communicate with applications on another device.

When you start RTOSDemo on your laptop, ping will usually not work.

What does work is to run a UDP server on a second laptop and adapt the IP-addresses. If that is also a Windows laptop you can run the RTOSDemo as well.