[lazarus] Working with Sockets
matooo at email.si
matooo at email.si
Sun Dec 8 13:07:52 EST 2002
Quoting Anders Jensen <outdoors at tiscali.no>:
> Har anyone any knowledge about working with sockets in Lazarus?
> I`m tearing my hair off here (and has little of it as it is) , trying
> to make
> a simple little p2p chat-client on SuSE 8.0, nuthin seems to work using
> the sockets-unit in FPC... or maybe I`m just doin it all wrong (very
> possible)
>
> AJ
>
Problem is larger in some ways than it seems. First major problem is that
sockets in ssockets unit don't respect kernel specifications for this kind of
communications.
Basically,
1. In linux accept (there is no check mode, accept just waits until it gets
result) should be run in a thread.
2. When accept is invoked another thread should be invoked which creates a
socket and this socket communicates with a client.
To conclude,
No multithreading, no fun
I'm making a CS socket communication and I've succesfully made all the
components I need, which I would be glade to contribute (as well as few bugs,
more likely security bugs and their solutions). There's just a fact that sockets
are not 100% tested and I'm still making a TInetJob queue which takes care if
there are more then one job for the same communication eg. copying multiple
files in different directions. They will be completed in friday (that's my
deadline for the project (mostly lazarus and bash cooperation) I've been working
last 7 months and communication is the last part of it). Just tell me where to
drop them or whom to send if you're interested. But I've corrected only
TInetSocket not TUnixSocket, which can just follow my example with Inet.
And explanation for security bugs.
There are some problems in your components, mainly involving forceably exiting
software after a bug. I understand that's common in Windows environment but Unix
isn't like that. Sockets have that one too. But there is a nicer example.
bug (XML#1)
1. Take xml file
2. Add some garbage at the end
3. Try to read it
4. Program exits with error
5. Mistake, it shouldn't do that, program might change it's running UID to root
meanwhile, so exiting would make current user root.
bug (sockets#1)
1. Client tryes to make communication that doesn't exist
2. Program invokes error
3. Read 5 in XML bug
All of your security bugs are involved in the same manner of exiting, so instead
of exiting with an error I just invoked Success: boolean which tells if
component is successful or not and TInvokeError with a console, log or gui mode
that reports error unpainfully, leave the rest to the program for correct
execution of exit if that's needed.
On the other hand, I'm making some special system services and deamons that must
change UID, GID and all others system vars constantly in the runtime, probably
typical Lazarus app isn't intended to do that, so I guess that with that bugs or
without lazarus is a great app that helped me a lot.
bye
-------------------
http://www.email.si
More information about the Lazarus
mailing list