[En-Nut-Discussion] NutUdpSendTo to myself?

Anpilogov Andrey def at fea.kiev.ua
Mon Oct 24 10:24:11 CEST 2005


I have such problem
Two sessions:
     NutThreadCreate ("udpin", UDPin, 0, 2048);
     NutThreadCreate ("udpout", UDPout, 0, 2048);

{
     UDPSOCKET *sock;
....
....
     if ((sock = NutUdpCreateSocket (Conf.server_portin))! = 0) {
         for (;;) {
             fprintf (ostream, "g");
             state = getc (ostream);

             for (n=1; n < =6; n ++) {
....
....
             NutUdpSendTo (sock, inet_addr (Conf.in_ip [n-1]), 
Conf.in_port [n-1], s, strlen (s));
        }
         NutUdpDestroySocket (sock);
    }

}

THREAD (UDPout, arg)
{
     UDPSOCKET *sock;
.....
.....
     if ((sock = NutUdpCreateSocket (Conf.server_portout))! = 0) {
         for (;;) {
             len = NutUdpReceiveFrom (sock, *rec_addr, *port, s, sizeof 
(s), 5000); /* Receive packet with timeout of 5s */
             if (len < = 0) {
                 fprintf (ostream, " \nNull data: %d\n ", len);
            } else {
                 strncpy (s, s, len);
                 fprintf (ostream, "\n%s\n", s);
....
....
            }
        }
         NutUdpDestroySocket (sock);
    }

}

Both THREAD work normally.
But as soon as I try to send UDP on myself
NutUdpSendTo (sock, inet_addr (Conf.in_ip [n-1]), Conf.in_port [n-1], s, 
strlen (s));
Where
Conf.in_ip [n-1] - IP of my device
Conf.in_port [n-1] - port with which works THREAD (UDPout, arg)

I receive " tcpdump -n "
11:11:43.437500 arp who-has 10.0.1.101 (ff:ff:ff:ff:ff:ff) tell 10.0.1.101
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
11:11:44.375000 IP 10.0.1.101.5001 > 10.0.1.1.6523: UDP, length 3
11:11:44.375000 IP 10.0.1.101.5001 > 10.0.1.1.6523: UDP, length 3
11:11:44.375000 IP 10.0.1.101.5001 > 10.0.1.1.6523: UDP, length 3
11:11:44.375000 IP 10.0.1.101.5001 > 10.0.1.1.6523: UDP, length 3
11:11:44.375000 IP 10.0.1.101.5001 > 10.0.1.1.6523: UDP, length 3
11:11:54.015625 arp who-has 10.0.1.101 (ff:ff:ff:ff:ff:ff) tell 10.0.1.101
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
11:11:54.953125 IP 10.0.1.101.5001 > 10.0.1.1.6523: UDP, length 3
11:11:54.953125 IP 10.0.1.101.5001 > 10.0.1.1.6523: UDP, length 3
11:11:54.953125 IP 10.0.1.101.5001 > 10.0.1.1.6523: UDP, length 3
11:11:54.953125 IP 10.0.1.101.5001 > 10.0.1.1.6523: UDP, length 3
11:11:54.953125 IP 10.0.1.101.5001 > 10.0.1.1.6523: UDP, length 3

How it to understand?
That is ethernut can not will connect on UDP to itself?



More information about the En-Nut-Discussion mailing list