[SOLVED] Problems with TCP/IP on Linux MInt 13? lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- bobc · 2012-09-01 16:48 I am having big trouble trying to get a socket program to run on Linux Mint 13. I have tried lnet 0.6.5 and synapse, with the simple httpget example programs. In all cases I get an error "host not found", but stepping through the code it appears the real problem is that an error occurs when trying to resolve the host name, but the error is not reported up to the caller. I have also tried 0.9.30-4 and 1.0. I have run similar samples on Windows and Linux Mint 12 machines, and these work ok. It seems to be a problem only on Mint 13, possibly an FPC problem? Or maybe I am just doing something stupid... Minimal example using synapse: Code: [Select]{$MODE DELPHI} Program testhttp; uses   httpsend, classes; var   HTTP: THTTPSend;   l: tstringlist; begin   HTTP := THTTPSend.Create;   l := TStringList.create;   try writeln (paramstr(1));     if not HTTP.HTTPMethod('GET', Paramstr(1)) then       begin writeln('ERROR');         writeln(Http.Resultcode);         writeln(Http.sock.lasterrordesc);       end     else       begin         writeln(Http.Resultcode, ' ', Http.Resultstring);         writeln;         writeln(Http.headers.text);         writeln;         l.loadfromstream(Http.Document);         writeln(l.text);      end;   finally     HTTP.Free;     l.free;   end; end. Compile/run sequence: Code: [Select]bob@zarquon ~/lazprogs/synapse/source/demo/FreePascal $ fpc testhttp.pas -Fu../../lib Free Pascal Compiler version 2.6.0-1 [2012/01/13] for i386 Copyright (c) 1993-2011 by Florian Klaempfl and others Target OS: Linux for i386 Compiling testhttp.pas Linking testhttp /usr/bin/ld: warning: link.res contains output sections; did you forget -T? 36 lines compiled, 0.1 sec bob@zarquon ~/lazprogs/synapse/source/demo/FreePascal $ ./testhttp http://www.google.co.uk/ http://www.google.co.uk/ ERROR 500 Host not found bob@zarquon ~/lazprogs/synapse/source/demo/FreePascal $ ping www.google.co.uk PING www-cctld.l.google.com (173.194.67.94) 56(84) bytes of data. 64 bytes from wi-in-f94.1e100.net (173.194.67.94): icmp_req=1 ttl=46 time=29.3 ms 64 bytes from wi-in-f94.1e100.net (173.194.67.94): icmp_req=2 ttl=46 time=29.0 ms 64 bytes from wi-in-f94.1e100.net (173.194.67.94): icmp_req=3 ttl=46 time=28.0 ms 64 bytes from wi-in-f94.1e100.net (173.194.67.94): icmp_req=4 ttl=46 time=29.1 ms 64 bytes from wi-in-f94.1e100.net (173.194.67.94): icmp_req=5 ttl=46 time=28.5 ms ---------------------------------------------------------------------- IndianaJones · 2012-09-01 17:23 Can you try the following code. it is just a draft, you can make some addition too. Code: [Select]var     HTTP: THTTPSend;     l: tstringlist; begin     HTTP := THTTPSend.Create;     l := TStringList.create;     try     writeln (paramstr(1));     if HttpGetText(Paramstr(1),l) then       WriteLn(l.text)     else       WriteLn('Cannot get the data');   finally     l.Free;   end; ---------------------------------------------------------------------- bobc · 2012-09-01 17:42 it writes "Cannot get the data" ---------------------------------------------------------------------- IndianaJones · 2012-09-01 18:35 Bobc, can you install wireshark and test the outgoing and incoming data? Regards. ---------------------------------------------------------------------- bobc · 2012-09-01 18:42 Ok, I found the problem, it is a problem with Linux Mint 13. glibc uses the file /etc/resolv.conf to get the nameservers. On Mint 13, this file is not created. (google: resolv.conf mint 13) Running "sudo dpkg-reconfigure resolvconf" and rebooting fixes up the problem, now I can run everything ok! I would have hoped for a better error message, although "host not found" is technically correct. This could be a confusing problem for unsuspecting Mint 13 users. ---------------------------------------------------------------------- BigChimp · 2012-09-02 07:18 @Bob: glad you found the solution. You might want to look through the bug tracker, AFAIR, an issue was raised about exactly this problem with resolv.conf ---------------------------------------------------------------------- esvignolo · 2012-09-03 16:16 Thanks! this works for me too. I had the same problem in linux mint 13. Quote from: bobc on September 01, 2012, 08:42:02 pmOk, I found the problem, it is a problem with Linux Mint 13. glibc uses the file /etc/resolv.conf to get the nameservers. On Mint 13, this file is not created. (google: resolv.conf mint 13) Running "sudo dpkg-reconfigure resolvconf" and rebooting fixes up the problem, now I can run everything ok! I would have hoped for a better error message, although "host not found" is technically correct. This could be a confusing problem for unsuspecting Mint 13 users. ---------------------------------------------------------------------- Dibo · 2012-10-25 09:28 Thanks for solution! I was wondering why my code suddenly stopped working. This is a synapse bug or linux mint? Why firefox and other web browser working fine? ---------------------------------------------------------------------- fabienwang · 2012-10-25 11:47 Quote from: Dibo on October 25, 2012, 11:28:35 amThanks for solution! I was wondering why my code suddenly stopped working. This is a synapse bug or linux mint? Why firefox and other web browser working fine? the problem is more a Distro bug, as many linux distro use the /etc/resolv.conf, but glibc should also search for other conf files (maybe in Mint13, there is another file for nameservers).