* * *

Author Topic: Recommended socket library?  (Read 2332 times)

Trenatos

  • Full Member
  • ***
  • Posts: 191
Recommended socket library?
« on: January 18, 2017, 05:31:26 pm »
I've tried to find a socket library, and keep running into issues.

The Wiki mentioned socket_laz, which failed to install and someone mentioned was outdated, the same person recommended fpsock, which doesn't work on OSX..

Can someone please recommend a decent socket library that works on OSX?

Thaddy

  • Hero Member
  • *****
  • Posts: 3640
Re: Recommended socket library?
« Reply #1 on: January 18, 2017, 05:55:19 pm »
I marked socket_laz as deprecated in the wiki and a candidate for removal since you last asked  because it does not work with recent versions of Lazarus any more and has been unmaintained for 12 years. Don't use it. Don't try to use it.
FPC comes with e.g. fpsock unit in the fcl-net package and fcl-web for higher level interfaces.
I don't know if there are Laz components for them, though.
You use fcl-web and fpc-net as classes.  Both the fcl-net and fcl-web packages come with extensive examples as default.
If you installed fpc 3 you already have these packages and these are the recommended ones.

Third party components are in Indy. See http://wiki.lazarus.freepascal.org/Indy_with_Lazarus
Third part classes are in synapse. https://sourceforge.net/p/synalist/code/HEAD/tree/trunk/ Synapse is very stable and doesn't need much updates. It is maintained..
« Last Edit: January 18, 2017, 06:03:55 pm by Thaddy »
Why do the Danish always try to fuck up any programming language?

Trenatos

  • Full Member
  • ***
  • Posts: 191
Re: Recommended socket library?
« Reply #2 on: January 18, 2017, 06:16:14 pm »
So what you're saying is that it's all there, I just have no idea how to find it.

I'm going to sound pissy, but shouldn't that be something the Wiki reflects?

The sockets page for example, I saw that you updated it, not with updated info but with a Deprecated notice.  That doesn't help anyone looking for how to use sockets, it just says Here's a page with info you can't use.

I love FPC, I've used it to build and release software as well as personal projects, but I keep running into this exact issue.

Things don't work, tons of outdated info, Wiki recommends things that don't even compile, it's horribly frustrating when I just want to code and get things done, it kills productivity.

I'm not blaming anyone, I know it's a volunteer project, I just wish I knew how to help make the overall state of things better.

I wish I could make updates and write Wiki pages, but the reality is that I'm not skilled enough at Pascal to be able to write accurate information beyond basic stuff.

Aside from ranting and feeling overall defeated every time I go to make something complex, fcl-web and fpc-net are the recommended ways of handling networking/web work?  Thank you, I'll go see what info/examples/tutorials I can find on those.

I appreciate your help, I truly honestly do, I want to make sure you know I'm not complaining about you or anyone else on this forum.

Thaddy

  • Hero Member
  • *****
  • Posts: 3640
Re: Recommended socket library?
« Reply #3 on: January 18, 2017, 06:45:02 pm »
In your FPC directory, not Lazarus,  there is a subdirectory called packages/fcl-net and a subdirectory called packages/fcl-web.
Examine these. Both have also an examples subdirectory.... see the wiki: http://wiki.freepascal.org/fcl-net  and http://wiki.freepascal.org/fcl-web
<grumpy mode on  >:D >
« Last Edit: January 18, 2017, 07:00:17 pm by Thaddy »
Why do the Danish always try to fuck up any programming language?

Trenatos

  • Full Member
  • ***
  • Posts: 191
Re: Recommended socket library?
« Reply #4 on: January 18, 2017, 07:17:47 pm »
Thanks Thaddy, I appreciate it.

As for the wiki..  :P

fcl-net just points to the examples folder and links to an external blog.
The examples in the blog uses fpsock, which doesn't work on OSX.

The fcl-web page looks a lot more complete, hopefully nothing in there is deprecated, this will come in handy for my next project.

Thaddy

  • Hero Member
  • *****
  • Posts: 3640
Re: Recommended socket library?
« Reply #5 on: January 18, 2017, 07:25:43 pm »
Why would fpsock not work on OSX? The author has only MAC's  O:-) O:-) he is often accused of. I will look into it. I have a Mac mini laying around for that.
I agree the wiki references for fcl-net are rather thin - and old -, but the examples are excellent. Maybe I move some of these to the wiki with some extra text.
The wiki references are old. The sourcecode isn't.
But the wiki is maintained by users and not by the core team: they only do the documentation proper and where applicable examples.
Most, if not all, of the FCL is well maintained.
« Last Edit: January 18, 2017, 07:29:09 pm by Thaddy »
Why do the Danish always try to fuck up any programming language?

Trenatos

  • Full Member
  • ***
  • Posts: 191
Re: Recommended socket library?
« Reply #6 on: January 18, 2017, 07:28:20 pm »
Someone mentioned that fpsock is only compiled for Linux? No idea what that means in practice.

Thaddy

  • Hero Member
  • *****
  • Posts: 3640
Re: Recommended socket library?
« Reply #7 on: January 18, 2017, 07:31:22 pm »
That it should work on a MAC  8-) Which is at its core a unix. But I'll look into it.

Well: it works on amiga, aros,netware, netwlibc, os2, unix and windows...

Not to put too fine a point to it:
- I would have examined that subdirectory and I would have examined the sourcecode.
- That is a lot more informative than some idiots hearsay that it doesn't work on MAC. It does probably. OSX is a UNIX. Sockets are lowlevel.

Both BSD (from which OSX is a fork) and Sockets stem from Berkeley, btw. At that low a level it almost is guaranteed to work on OSX.

"Berkeley sockets is an application programming interface (API) for Internet sockets and Unix domain sockets, used for inter-process communication (IPC). It is commonly implemented as a library of linkable modules. It originated with the 4.2BSD Unix released in 1983."

[edit] It works on my intel mac mini with snow leopard. I have to test with newer versions but I expect that you should not have any problems at all..
One caveat: I often modify RTL sources - that only get noticed when I do a new checkout- and I did not use the MAC for a couple of months with FPC.
« Last Edit: January 18, 2017, 07:53:45 pm by Thaddy »
Why do the Danish always try to fuck up any programming language?

Trenatos

  • Full Member
  • ***
  • Posts: 191
Re: Recommended socket library?
« Reply #8 on: January 18, 2017, 10:30:26 pm »
When I try to use fpsock, I get an error, it definitely does not work for me, not just hearsay  ;)

Could be my version of OSX, I'm on El Capitan.

It sounded odd to me too, as I'm aware that OSX is Linux (Did not know it was a BSD fork specifically).

I did nothing special, I grabbed a new download the other day (First setup on this machine) and tried the example from the Pascal Warrior page, and immediately get an error on the uses fpsock.

molly

  • Hero Member
  • *****
  • Posts: 1612
Re: Recommended socket library?
« Reply #9 on: January 18, 2017, 11:02:23 pm »
When I try to use fpsock, I get an error, it definitely does not work for me, not just hearsay  ;)
Well, it seems that you are correct and fpsock was/is not compiled for mac.

fpcmake:
Code: [Select]
#
#   Makefile.fpc for FCL net units
#

[package]
name=fcl-net
version=3.0.0

[target]
units_linux=netdb resolve ssockets fpsock cnetdb
units_freebsd=netdb resolve ssockets fpsock cnetdb
units_netbsd=netdb resolve ssockets fpsock
units_openbsd=netdb resolve ssockets fpsock
units_darwin=netdb resolve ssockets
units_iphonesim=netdb resolve ssockets
units_solaris=netdb resolve ssockets
units_qnx=netdb resolve ssockets
units_beos=netdb resolve ssockets
units_haiku=netdb resolve ssockets
units_emx=resolve ssockets
units_os2=resolve ssockets
units_win32=resolve ssockets
units_win64=resolve ssockets
units_wince=resolve ssockets
units_aros=resolve ssockets

[require]
packages=fcl-base fcl-xml fcl-passrc fcl-async

[compiler]
options=-S2h
includedir=src/$(OS_TARGET)
includedir_linux=src/unix
includedir_freebsd=src/unix
includedir_darwin=src/unix
includedir_iphonesim=src/unix
includedir_netbsd=src/unix
includedir_openbsd=src/unix
includedir_solaris=src/unix
includedir_qnx=src/unix
includedir_beos=src/unix
includedir_haiku=src/unix
includedir_emx=src/os2
includedir_win32=src/win
includedir_win64=src/win
includedir_wince=src/win
sourcedir=src/$(OS_TARGET) src

[install]
fpcpackage=y

[default]
fpcdir=../..

[rules]
.NOTPARALLEL:
You should be able to use sockets using procedural approach though (fpc 3.0.0), and of course yiou can use the classes from ssockets.
« Last Edit: January 18, 2017, 11:09:50 pm by molly »

Trenatos

  • Full Member
  • ***
  • Posts: 191
Re: Recommended socket library?
« Reply #10 on: January 19, 2017, 02:40:14 am »
So I grabbed the fpc 3.0.0 source off of svn, added fpsock to units_darwin and ran make cycle in fpc/compiler.

But uh, no idea what to do now..

No idea where files ended up or what to point Lazarus to..

molly

  • Hero Member
  • *****
  • Posts: 1612
Re: Recommended socket library?
« Reply #11 on: January 19, 2017, 05:11:26 am »
@Trenatos:
Perhaps a dumb question from my side but, what is it that you actually wish to accomplish ?

You asked specifically for sockets, and that is usually asked for a specific reason (other people normally ask for internet components/classes, tcp/ip components or similar).

That implies that you know how to handle (raw) sockets, e.g. you wish to implement your own protocols etc.

Trenatos

  • Full Member
  • ***
  • Posts: 191
Re: Recommended socket library?
« Reply #12 on: January 19, 2017, 05:47:40 am »
Several reasons actually.

I wrote a simple IRC client in LiveCode a few years back, I want to take a proper stab at that again and expand on it as I got inspired by Slack, I'm also planning to implement a simple table top-style game in a network fashion.

Yes, I'll be writing my own protocols, for sockets I'm just looking at networking, I won't be dealing with complex data for any of this.

I'm a web developer by profession, so yeah I'm also looking at using FPC/Lazarus as a web stack (Possibly with Brook, but surprise-surprise, it doesn't compile on El Capitan..), but that's what I do for a living, the socket stuff is mostly for fun.

As for what I'm trying to accomplish with compiling FPC is just me trying to move forward and testing to see if just adding fpsock to the units_darwin works, solving my own problem rather than hoping that someone else takes enough pity on me to do it.

I do try to solve my own problems first, but I ran into the issue above, I compiled it but now what?.. lol

molly

  • Hero Member
  • *****
  • Posts: 1612
Re: Recommended socket library?
« Reply #13 on: January 19, 2017, 06:05:02 am »
@Trenatos:
Ok, i did not wanted to sound too nosy. Just thought it was perhaps better to recommend to use a ready to go (more extended) framework.

Alas, i know that situation all to well that not all platforms are supported  :'(

Ok, i don't believe an irc example is available but, recently someone wanted to create his/her own http server, here. Just ignore the winsock part there  ;)

In case you've compiled your own fpsock unit then it is located probably in the place where you compiled it, e.g. inside fcl-net directory of your sources (no clue as of what exactly you did to compile it). In case of a installed fpc/lazarus, copy the unit (and/or sources) over to your installation. you should be looking for "fpsock.ppu".

A simple uses fpsock should be enough. Do relaize that there might be a perfectly valid reason why fpsock is not compiled for darwin by default (deprecated for example). units sockets and ssocket can be used as well.

fcl-web complements fcl-net and provides some examples such as a simple http server and also a simple http client.

« Last Edit: January 19, 2017, 06:06:37 am by molly »

Thaddy

  • Hero Member
  • *****
  • Posts: 3640
Re: Recommended socket library?
« Reply #14 on: January 19, 2017, 10:16:11 am »
Can you give me some more information about the error you get.
You can simply add the path to the sources and try again.
I have no clue why fpsock is not compiled as package for OSX.
As I said: I can use it, but maybe I made some changes. I will try and find what I did exactly.
It can also be the case that it used to be enabled and is now disabled for some reason I am not aware of.
Why do the Danish always try to fuck up any programming language?

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus