sendto() and gateway problem

We are using a digiconnect me C-type with our own software and want to send an UDP-telegram with sendto().
This works fine, when the destination is in the same network.
But when the device finds out (with the subnet mask), that it must send the telegram to its gateway address, sendto() delivers (-1)
What is wrong? Do we have to enable the gateway function first? If yes, how?

Device IP


–> sendto() does not send the message.
If we change the subnet mask to (so that the device beliefs, that the destination is in the same network), sendto() sends the message. Well, but of course it won’t reach its destination…)

We are using sendto() with flags=0x0

Has anyone an idea?`



If I remember, you need to send your message to your gateway ( Then the gateway can transfer the message to at the condition that the gateway has been configured to route the UDP messages received on port X to the address I am not a pro in network, but I think it works like that.

An other solution I have found when trying to discover my DIGIs on the same network, but with different IP address: if you use the “fast IP” API to send back a message, the message is directly sent to the address, without regarding whether the IP is in the same network or not.

Of course it works only for response messages. But you could try the “fast socket” API, maybe it works the same way.


Thank you for your reply,
the first part of your reply is exactly what we want to do.

As I understand it: The device wants to send an message. It checks with the subnet mask, wether the destination is in the same subnet. If not, like in our case, it puts the message in an “envelope” and sends the complete thing to the gateway address, the gateway will know where to find the external recipient.

And exactly that is not working. The device does not send the message to the gateway, it does nothing, sendto() returns with -1.

We are using static adresses to keep things simple and I’ve double-checked, that there is a valid gateway address and mask in the NVrams.

What could be the reason, that this gateway-function is not working?

Thank-you for your help