SOLVED UDP broadcast listener lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- samsvl · 2018-11-17 16:30 I have an outside thermometer broadcasting temperature to my lan with address 192.168.0.255, port 8088. I am trying to receive the data on my win8.1 pc using a freepascal program below. It runs up till writeln('fpbind ',k), writes zero, and then it seems to hang, while the thermometer is broadcasting. Can anybody help me? uses sockets; var    S: longint;    SA: SockAddr;    k: longint;    buf: array[0..255] of char;    L: ssize_t;    len: Tsocklen;    broadcast: integer; begin S := fpSocket(AF_INET,SOCK_DGRAM,0); writeln('socket ',S); SA.sin_family := AF_INET; SA.sin_port := htons(8088); SA.sin_addr.s_addr := htonl(INADDR_ANY); {StrToHostAddr('');  } broadcast := 1; k := fpsetsockopt(S,SOL_SOCKET,SO_BROADCAST,@broadcast,sizeof(broadcast)); writeln('fpsetsockopt ',k); k := fpBind (S, @SA, sizeof(SA)); writeln('fpbind ',k); len := sizeof(SA); L := fprecvfrom(S,@buf[0],255,0,@SA,@len); write('fprecvfrom ',L); readln; write(SocketError); readln; end. ---------------------------------------------------------------------- skalogryz · 2018-11-17 18:03 Make sure you’re not blocked by the firewall ---------------------------------------------------------------------- samsvl · 2018-11-17 20:24 Thanks for your reaction. But all is within my lan, so I don't expect firewall problems. Moreover, a simple python implementation on my Raspberry Pi does work. ---------------------------------------------------------------------- engkin · 2018-11-18 00:54 Quote from: samsvl on November 17, 2018, 05:30:22 pmI have an outside thermometer Just curious, which thermometer are you using? Quote from: samsvl on November 17, 2018, 05:30:22 pmbroadcasting temperature to my lan with address 192.168.0.255, port 8088.instead of 192.168.0.255, try 255.255.255.255 Quote from: samsvl on November 17, 2018, 05:30:22 pm I am trying to receive the data on my win8.1 pc using a freepascal program below.Which FreePascal version? 32 or 64-bit? Is your win8.1 64-bit? Quote from: samsvl on November 17, 2018, 05:30:22 pmIt runs up till writeln('fpbind ',k), writes zero, and then it seems to hang, while the thermometer is broadcasting.This sounds to me like it's waiting to receive data: QuoteIf no incoming data is available at the socket, the recvfrom function blocks and waits for data to arrive according to the blocking rules defined for WSARecv Quote from: samsvl on November 17, 2018, 05:30:22 pmCan anybody help me?What is your network setup? I assume you already used something like WireShark to make sure your computer is receiving the broadcasted temperature? ---------------------------------------------------------------------- samsvl · 2018-11-18 12:34 Quote from: engkin on November 18, 2018, 01:54:58 amQuote from: samsvl on November 17, 2018, 05:30:22 pmI have an outside thermometer Just curious, which thermometer are you using? Homebrew: an RTD connected to the ADC of an ATtiny45 microcontroller which transfers the data via SPI to an ENC28J60 SPI to ethernet converter, connected to my LAN Quote from: samsvl on November 17, 2018, 05:30:22 pmbroadcasting temperature to my lan with address 192.168.0.255, port 8088.instead of 192.168.0.255, try 255.255.255.255 I'll implement your suggestion, will take some time because the address is hard coded in the ATtiny program Quote from: samsvl on November 17, 2018, 05:30:22 pm I am trying to receive the data on my win8.1 pc using a freepascal program below.Which FreePascal version? 32 or 64-bit? 3.0.2 32 bit Is your win8.1 64-bit? yes Quote from: samsvl on November 17, 2018, 05:30:22 pmIt runs up till writeln('fpbind ',k), writes zero, and then it seems to hang, while the thermometer is broadcasting.This sounds to me like it's waiting to receive data: QuoteIf no incoming data is available at the socket, the recvfrom function blocks and waits for data to arrive according to the blocking rules defined for WSARecvYes, that's what I think also. But why? Quote from: samsvl on November 17, 2018, 05:30:22 pmCan anybody help me?What is your network setup? I assume you already used something like WireShark to make sure your computer is receiving the broadcasted temperature? Yes, Wireshark shows the broadcast message, but since there is no client-server communication I can't see if my PC accepts the message. I just installed the script on my Raspberry PI A connencted to the same LAN, and there it runs without problems. So the issue must be windows related. Again, thanks for your reaction, Sam ---------------------------------------------------------------------- Bram71 · 2018-11-18 14:01 Can it be the windows firewall blocking the traffic? Just disable it for a moment to check... ---------------------------------------------------------------------- lucamar · 2018-11-18 14:29 Also, while you're (re-)checking the firewall make double-sure that both the IP address and the port are available for UDP to your application. I had a problem like this once and it was because the firewall was blocking the port. Good luck! ---------------------------------------------------------------------- samsvl · 2018-11-18 19:27 You all pointed to the firewall, and you all were right !!! Thanks a lot, problem solved.