Home/Support/Support Forum/sendto() and gateway problem
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

sendto() and gateway problem

0 votes
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?


Example:
Device IP 192.168.150.235
Subnetmask 255.255.255.0
Gateway 192.168.150.254

Destination 192.168.110.106

--> sendto() does not send the message.
If we change the subnet mask to 255.255.0.0 (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?`

Thank-you!
asked May 18, 2006 in NET+OS by ArthurDent New to the Community (6 points)
recategorized Dec 18, 2013 by tuxembb

Please log in or register to answer this question.

2 Answers

0 votes
Hi,

If I remember, you need to send your message to your gateway (192.168.150.254). Then the gateway can transfer the message to 192.168.110.106 at the condition that the gateway has been configured to route the UDP messages received on port X to the address 192.168.110.106. 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.

Paul
answered May 18, 2006 by pevandenburie Community Contributor (72 points)
0 votes
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

Jo
answered May 18, 2006 by ArthurDent New to the Community (6 points)
...