Forum > Packages and Libraries
[SOLVED] Synapse: How to communicate with *.local machine on *nix.
tk:
I have a problem using the Synapse library on *nix systems (Linux, MAC).
The following code works on Windows but does not on *nix:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.FormCreate(Sender: TObject);var sock: TUDPBlockSocket;begin sock := TUDPBlockSocket.Create; try sock.Connect('mypc.local', '1000'); sock.SendByte(0); sock.CloseSocket; finally sock.Free; end;end;
Synapse calls Winsock.GetAddrInfo on Windows which works and returns correct IP.
But it calls netdb's ResolveName on *nix, which directly implements DNS protocol and does not work (cannot work by design).
rvk:
--- Quote from: tk on November 04, 2024, 09:09:17 am ---But it calls netdb's ResolveName on *nix, which directly implements DNS protocol and does not work (cannot work by design).
--- End quote ---
--- Quote ---and netdb resolvename only checks the DNS servers listed in /etc/resolv.conf.
--- End quote ---
https://wiki.freepascal.org/Netdb
So you have a DNS server in resolv.conf which doesn't resolve mypc.local ???
Why does that server not resolve your mypc hostname?
TRon:
Note that ports < 1024 are 'protected' so unless you are running as root (or have another provision in place that allows you).
rvk:
--- Quote from: TRon on November 04, 2024, 09:21:12 am ---Note that ports < 1024 are 'protected' so unless you are running as root (or have another provision in place that allows you).
--- End quote ---
+1 Haha. Good one for spotting that :D
tk:
--- Quote from: rvk on November 04, 2024, 09:19:57 am ---So you have a DNS server in resolv.conf which doesn't resolve mypc.local ???
Why does that server not resolve your mypc hostname?
--- End quote ---
$ nslookup mypc.local reports error on all systems.
$ ping mypc.local works on all systems.
https://learn.microsoft.com/en-us/windows/win32/api/ws2tcpip/nf-ws2tcpip-getaddrinfo
The getaddrinfo function provides protocol-independent translation from an ANSI host name to an address.
The problem on *nix is that Synapse uses DNS protocol by default which is incorrect.
--- Quote from: TRon on November 04, 2024, 09:21:12 am ---Note that ports < 1024 are 'protected' so unless you are running as root (or have another provision in place that allows you).
--- End quote ---
Sorry just mistyped in this sample. Not the cause of this problem (in my program I use dynamic ports in the range 49152–65535, eg. 50000).
Navigation
[0] Message Index
[#] Next page