Networking with lazarus fpc on macosx lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- facom4ever · 2012-01-29 21:45 Hello, Can you help me please? I am with lazarus and fpc on Macosx. I have to allow my application server to send txt files to my client server. They are both on the same network. I guess I have to use ftp protocol for that. I tried to install synaps, indy and lnet. But has no one use components I have no clue how to do net working taks with them . Tried to search but have not found something clear. Anyone can sugest me what and how to use ? Thanks !! Falcom ---------------------------------------------------------------------- everton · 2012-01-29 23:30 I've used Indy tcp core to send text and binary files beetween server- client application. It's easy to do. Make the connection: Host and Port basicly. Server side: onExecute AContext.Connection.IOHandler.Write or Read. Client side: IdTCPClient.IOHandler.Write or Read. It's easy but i'm having problems to make the Indy work now that a put the svn version of lazarus, the projects that contains Indy components stoped to compile. The message is: Can't find the unit x of indy. Some problem with the path. The strange is that the package compile and is installed in the ide. Is very like some path to update in the FPC. ---------------------------------------------------------------------- everton · 2012-01-29 23:37 To transfer text or binary files the tip is to send first the size of the file and on the read procedure specify that. ---------------------------------------------------------------------- IndianaJones · 2012-01-30 00:11 I havent tried Indy recently so not sure if it works for Mac OS or not but pretty sure that you can use ftp synapse for mac. Also lNet doesnt support Mac platform yet. It will be supported version 0.7 For the synapse examples google it as "ararat synapse" Thanks. ---------------------------------------------------------------------- BigChimp · 2012-01-30 05:05 Though I haven't tried it on OSX, synapse was easy to install (just copy some files) and use, I never tried Indy... It never hurts to look at the wiki, either... there's an SSH client example though, not an FTP example: http://wiki.lazarus.freepascal.org/Synapse ---------------------------------------------------------------------- Phil · 2012-01-30 20:31 Don't forget that FPC 2.6.0 now includes HTTP client and other useful units. I've transitioned away from Indy on OS X and use fphttpclient, etc. Note that for iOS, none of the existing HTTP clients work (Indy, Synapse, FP). With iOS, you can use or extend this simple HTTP client: http://web.me.com/macpgmr/ObjP/Xcode4/ns_url_request.pas http://web.me.com/macpgmr/ObjP/Xcode4/NSHelpers.pas  (string helper unit) This also works with OS X if you need something simple. Note requires FPC 2.6.0 or later. Thanks. -Phil ---------------------------------------------------------------------- goodname · 2012-01-31 04:00 I'm guessing the http, tcp code is part of fcl-web. http://wiki.freepascal.org/Web_Service_Toolkit#Connection_Parameters Looks like fcl-web is based on synapse or ics. Since both are implemented are there uses cases to use one or the other? I have successfully used lNET with a wince client and a windows server. Is it possible to use the tcp server component in fcl-web to support macosx with a lNET client? ---------------------------------------------------------------------- Phil · 2012-01-31 04:23 You're confusing two different packages. fcl_web <> WST fcl_web is not based on Synapse or ICS WST is not "based" on Synapse or ICS - you can use it with any of 5 different HTTP client libraries, as described here in using it with iOS: http://web.me.com/macpgmr/ObjP/Xcode4/ObjP_Part11.html Not sure if I follow your question. Take a look at the example apps included with WST to see what you can do with it. Thanks. -Phil ---------------------------------------------------------------------- BigChimp · 2012-01-31 06:31 I suspect goodname is looking for some examples of how this FPC 2.6 fphttpclient is used... Probably somewhere in the FPC source code itself, but haven't tried to look lately... ---------------------------------------------------------------------- marcov · 2012-01-31 10:06 I wouldn't move to lnet (or fphttpclient) out of installation problems.  LNet is rather less forgiving then synapse or Indy, and if you can't deal with installing those, lnet is probably not really for you either. The advantages of LNET lie more in its minimalism and better alignment with *nix server models. ---------------------------------------------------------------------- felipemdc · 2012-01-31 10:49 I use lNet in Mac OS X and I didn't have any problems. ---------------------------------------------------------------------- everton · 2012-01-31 11:17 Indy has a lot of useful functionalities. The hell is that separated folder ../fpc that the compiler easily doesn`t find. I don`t know why! ---------------------------------------------------------------------- marcov · 2012-01-31 11:34 Quote from: everton on January 31, 2012, 12:17:11 pmIndy has a lot of useful functionalities. The hell is that separated folder ../fpc that the compiler easily doesn`t find. I don`t know why! The first thing I do if I test with Indy is to delete all duplicate files in the Indy archive. If any. (specially the .inc files). That saves half of the trouble. Indy only wants to rectify that in the next major version that is afaik constantly postponed. ---------------------------------------------------------------------- goodname · 2012-01-31 17:27 I should clarify. My experience with networking is limited. Research done 8-9 months ago on sending text messages between applications lead to TCP client and server using lNet on WinCE/Windows. This setup has proven itself in a live environment. Now thinking about porting the TCP server to OSX and I find that it is now possible build a TCP or HTTP server using units bundled with fpc. Suppose I'm asking can the bundled TCP server units work with a lNet client? Good to hear that lNet works on OSX today even if it is not official yet. Hopefully that could make a port a simple as installing Lazarus on OSX and compiling. ---------------------------------------------------------------------- facom4ever · 2012-02-02 13:49 I installed Synapse. It complies at least I can do ftp commands now, but isn't the an easier sollution to send file ? I need to setup a ftp server...... EDIT: That sucks. It compiltes but I can't even use the function ping. Some function seem to work only on windows environment. @Everton how did you do to install on macosx ? for me it doesnt install the package because it doesnt compile... @felipemdc i can only install lnetbase, the components seem to be incompatible Macosx how did you do ? ---------------------------------------------------------------------- felipemdc · 2012-02-02 15:36 Quote from: facom4ever on February 02, 2012, 02:49:14 pm@felipemdc i can only install lnetbase, the components seem to be incompatible Macosx how did you do ? Try this lnet from here: http://openpokergrid.svn.sourceforge.net/viewvc/openpokergrid/Componen ts/lnet/ ---------------------------------------------------------------------- facom4ever · 2012-02-03 08:08 Oh yeah ! This one works mate =D. Wonderful ! Thanks ---------------------------------------------------------------------- marcov · 2012-02-03 10:45 QuoteDon't forget that FPC 2.6.0 now includes HTTP client and other useful units. I've transitioned away from Indy on OS X and use fphttpclient, etc. If webprogramming is serious business for you, I urge you to be careful with netdb, and change it to cnetdb (which plugs into libc) as much as possible for DNS resolving. NetDB has a problem, but more importantly is sensitive, IMHO it should be deprecated for all but the simplest uses. Quote from: Phil on January 30, 2012, 09:31:16 pmNote that for iOS, none of the existing HTTP clients work (Indy, Synapse, FP). With iOS, I was under the impression that only a connection needs to be initiated via some objc call, and that then sockets programming works. ---------------------------------------------------------------------- everton · 2012-02-04 18:48 Try to go on compiler options of the package remove from the path the "../fpc" press ok and compile will error, open again the compiler options reinsert the "../fpc" press ok and compile again is supposed to work then install, sometimes that procedure worked with me. Also give preference to put the package on lazarus dir/components. I've already be able to install on a mac, but after a download the svn version and imprudently override the already instaled version they stop do compile. Now i don't been able to install Indy anyway. Wich is very weard because i've already tried to remove all the installation files of fpc and lazarus and get back that enviroment of before but i wasn't able in anyway i've tried. By now isn't urgent to me to make work on a mac, the windows project is the one that i'm working on. But in the future i'll have to again. If you or anybody find out how, please send to us the tips for. ---------------------------------------------------------------------- facom4ever · 2012-02-06 09:03 Urg Developping for mac is a nightmare >_<... Even I could install lnet, the tcp example doesnt seem to work. When I press connect nothing happens -___-'''. Don't understand why there is no library working fine =(. Or maybe I am dumb and missed something. ---------------------------------------------------------------------- everton · 2012-02-06 13:24 I`ve already used Indy on mac try to do this: remove and add from the package compiler options the path "../fpc". remove compile, add compile and install, sometimes this works. ---------------------------------------------------------------------- facom4ever · 2012-02-06 14:05 Oh I managed few minutes ago to compile by moving fpc files to lazarus folder XD... guess that ../fpc would have worked too.... ---------------------------------------------------------------------- facom4ever · 2012-02-07 09:07 On Indy if I turn active := true the component IdTCPServer1 I get runerror(232) which is related to cthreads... I checked on lazarus.pp and cthreads is defined to be use. Maybe it is a problem with thread-driver as saw on google, but don't know what is it... Anyone an idea or got this problem ?