I'm trying to use the Ethernet.lib library with a 750-842 controller. I want to make an UDP server listenning to UDP packet wich are broadcasted on the network.
I'm doing this:
VARsocket:ETHERNET_SERVER_OPEN;Read:ETHERNET_READ;END_VARIF(socket.SOCKET=0)THENΒ Β socket(EN:=1,TYP:=SOCK_DGRAM,PROTO:=IPPROTO_UDP,PORT:=4545);END_IFRead(EN:=1,SOCKET:=socket.SOCKET,DATA:=buffer);Read(EN:=0,DATA:=buffer);IF(Read.LEN_OUT>0)THENΒ Β (* Do somthing *)END_IF
The socket is successfully created with no error, but when a packet comes nothing is read from the ETHERNET_READ function block...
Why? Does anybody know if I've done something wrong?
Thank
Raoul
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello all.
I'm trying to use the Ethernet.lib library with a 750-842 controller. I want to make an UDP server listenning to UDP packet wich are broadcasted on the network.
I'm doing this:
The socket is successfully created with no error, but when a packet comes nothing is read from the ETHERNET_READ function block...
Why? Does anybody know if I've done something wrong?
Thank
Raoul
Hi
Did you try it like this:
Read(EN:=1, SOCKET:=socket.SOCKET, DATA:=buffer);
IF (Read.LEN_OUT > 0) THEN
END_IF
Yes I tried that, but It's exactly the same...
Raoul
Hi
I have a (fully working and tested) Sample for you.
Maybe it helps you to understand the mechanism.
Greets
Erik
WagoEthernetServer.zip [12.42 KiB] (forum.codesys.com)
Thank you, I'll try this example...
Raoul