NetUDP server and client library

agraham

Expert
Licensed User
This library supercedes, and includes the fuctionality of, the NetUDPclient library. This new version includes a UDP server object and a DNS lookup capability. I removed "client" from the name of the library to better reflect its broader capability.

Sources, help and demos are included in the archive as usual.
 

Attachments

Byak@

Active Member
Licensed User
Hello Agraham. i don't understand what happend if
1)2 or more clients send data an ONE moment?how work event in this situation?
2)one client sent data.event fired and subprogram in event begin.and in this moment (subprogram not ended) second cliend sent data.what happend?
:sign0104:
 

micro

Well-Known Member
Licensed User
Hi Agraham
but client works only with localname of the server and not with IP address?
 

micro

Well-Known Member
Licensed User
the client connects to the server when I enter the server name and not the ip
 

agraham

Expert
Licensed User
It should accept either

IPAddress.Parse Method (System.Net)

B4X:
public void Start(String URLorIP, int txPort, int rxPort)
        {
            if (!connected)
            {

                try
                {
                    txendpoint = new IPEndPoint(IPAddress.Parse(URLorIP), txPort);
                }
                catch (FormatException)
                {
                    //not an ip address... try resolving through DNS
                    IPHostEntry entry = System.Net.Dns.GetHostEntry(URLorIP);
                    txendpoint = new IPEndPoint(entry.AddressList[0], txPort);
                }
                client = new UdpClient(rxPort);
                client.Connect(txendpoint);
                rxthread = new System.Threading.Thread(new ThreadStart(ReceiveThread));
                connected = true;
                rxthread.Start();
            }
        }
 

Zenerdiode

Active Member
Licensed User
Hello Andrew,

I'm trying to use your NetUDP library to talk to a small logging device. The connection is just a direct cross-over CAT5 network cable. The device has an in-built webserver and I can connect to that just fine. However it also accepst commands via UDP for administrative tasks.

I am able to send a UDP request with your Library; also I know the device responds as I have looked at the network traffic with Wireshark. However the _Received event is never fired. The Wireshark traffic is identical when I use the logger manufacturer's tool, so the attached screenshot is indeed identical if I use the manufacturer's tool or my program.

I have tried all combinations of having txPort and rxPort set to 40134 and 3003.
 

Attachments

agraham

Expert
Licensed User
From that Wireshark capture it looks like your device is replying to the wrong port. The device is replying to 10.0.1.1:40134 but the UDP client code is expecting the reply to come in on 10.0.1.1:41034 . By the way the client sends through the same port as it is told to listen on.
 

Zenerdiode

Active Member
Licensed User
In the nicest possible way, you may have directed me to a little bit of 'number dyslexia' :) I checked to make sure I spelled 'Received' correctly in the event sub too.

I'll try when I get in from work tonight.
 
Top