UDP Library/Component Suggestions lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- lgrfbs · 2021-09-21 04:51 Hello Now I've found some inspiration again to program a little. I need a UDP library/component that works for both Linux and Windows, what should I look for? ---------------------------------------------------------------------- sstvmaster · 2021-09-21 08:40 Here is an overview of network libraries: https://wiki.lazarus.freepascal.org/Networking_libraries You can use: LNet, Indy or Synapse. ---------------------------------------------------------------------- franciscoluiz · 2021-09-21 14:51 pls try upd super components https://sourceforge.net/projects/udpsupercomponents/ ---------------------------------------------------------------------- Warfley · 2021-09-23 01:00 I wouldn't use a library for UDP. UDP is a very simple protocol (as you can only recieve full datagrams every transmission is only a single read or write). With the sockets unit this is very easy: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses sockets; var  Sock: TSocket;  Addr: PSockAddr_in;  AddrLen: PSizeInt;  AString: String;  DataSize: SizeInt;begin  Sock := fpsocket(AF_INET, SOCK_DGRAM, 0);  if Sock < 0 then    WriteLn('Something  went horribly wrong');  New(Addr);  New(AddrLen);  try    // Send a string stored in AString to HOST_IP at PORT:    // Set address of receiver    Addr^.sin_family := AF_INET;    Addr^.sin_port := HToNS(PORT);    Addr^.sin_addr.s_addr := LongWord(StrToNetAddr(HOST_IP));    // perform sending operation    fpSendTo(Sock,  Pointer(AString), AString.Length, 0, Addr, SizeOf(Addr^);    // Receive Data and write to AString:    SetLength(AString, 512); // 512 is the maximum datagram size in many implementations    DataSize := fpRecvFrom(Sock, AString, AString.Length, 0, Addr, AddrLen);    SetLength(AString, DataSize);  WriteLn('Data received from ', NetAddrToStr(Addr^.sin_addr.s_addr), ': ' . AString);  finally    Dispose(Addr);    Dispose(AddrLen);  end;end; Or to simplify: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses sockets; procedure SendString(Sock: TSocket; const AHost: String; APort: Word, const Data: String);var  Addr: TSockAddr_IN;begin  Addr^.sin_family := AF_INET;  Addr^.sin_port := HToNS(APort);  Addr^.sin_addr.s_addr := LongWord(StrToNetAddr(AHost));  fpSendTo(Sock, Pointer(Data), Data.Length, 0, @Addr, SizeOf(Addr));end; procedure ReceiveString(Sock: TSocket; out SenderHost: String; out SenderPort: Word): String;var  addr: PSockAddr_IN;  addrLen: PSizeInt;  DataSize: SizeInt;begin  New(addr);  New(addrLen);  try    SetLength(Result, 512);    DataSize := fpRecvFrom(Sock, Pointer(Result), Result.Length, 0, addr, addrLen);    SetLength(Result, DataSize);    SenderHost := NetAddrToStr(addr^.sin_addr.s_addr);    SenderPort := NToHs(addr.sin_port);  finally    Dispose(addr);    Dispose(addrLen);  end;end; var  Sock: TSocket;  data: String;  HostIP: String = '127.0.0.1';  HostPort: Word = 1337;begin  Sock := fpSocket(AF_INET, SOCK_DGRAM, 0);  if Sock < 0 then    Exit; // error;  // Send console input to host  ReadLn(data);  SendString(Sock, HostIP, Port, data);  // Receive data:  data := ReceiveString(Sock, HostIP, Port);  WriteLn('Received from ', HostIP, ':', Port, ' ', data);end; This is pretty much all you need to work with UDP. I don't see any reason to include some third party librar for using something that can be expressed with two functions having each less than 10 lines of code