Server Socket Queues

I need to write an application to act as an interface between several cash register systems (all the same type) and a customer loyalty system.

I can write procedures to pick up data from the customer loyalty system without any problems.

I have written a procedure using TServerSocket to receive packets from a socket client and it works OK most of the time.

The problems I am having are:
   1. There seem to be many different errors I need to trap and handle.  I don’t know what these all are or how to handle them.  e.g. Socket Connection errors.

   2. I am using a procedure called: TMain_Form.CashRegisters_ServerClientRead(Sender: Tobject; Socket: TCustomWinSocket);.  When I receive only one packet at a time, it works OK.  If I receive a second packet while this procedure is processing the first packet, it stops processing the first packet until the latest packet has been handled.
I want the program to process packets on a first-in first-served basis.

I am fairly new to Delphi programming and have no experience (until a few days ago) using sockets.  I don’t have a lot of time to finish this project.

My preference would be to find a component that will handle the errors and queueing for me.

Are there any components available to do this?  I would prefer freeware or shareware so I can try before I buy.
LVL 13
Who is Participating?

Improve company productivity with a Business Account.Sign Up

DragonSlayerConnect With a Mentor Commented:
Have you tried the Indy components? (they come with Delphi6 and can also be downloaded from

Check out their examples in using threads... there you will see how they create new threads to handle each request simultaneously.

>>If I receive a second packet
while this procedure is processing the first packet, it stops processing the first packet until the
latest packet has been handled.<<

so you're using non-blocking sockets
make the server thread-blocking
akbAuthor Commented:
Thanks Lee.  That may help a little, but it doesn't overcome my first problem and lack of experience.

I'd really like to find an add-on that will handle the socket for me.
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

akbAuthor Commented:
Thanks DragonSlayer.  The Indy components look like they may be useful.  I have downloaded them and will try them out shortly.

This component is what you need:

Good Luck!

akbAuthor Commented:
Thanks freshman3k.  I'll take a look at these components as well.
if you're going to use indy then take a look at some of my helper functions @
akbAuthor Commented:
Thanks Lee Nover.
akbAuthor Commented:
Thanks Lee Nover.
akbAuthor Commented:
I am trying out the Indy components.  I have replaced my old TServerSocket with the Indy TldTCPServer.  And I'm using the OnExecute event instead of the OnClientRead event.

The problem is, I am also caling Apollo database components to look up data in my old DBF files.  As soon as I call the Apollo Seek component, I get an error box about 30 times and no returned data.  The error is:

Data Driver Error
Invalid work area

I am happy to increase the points for help on this problem.
this kinda doesn't fit into the current topic
but still .. I think it's coz the OnExecute event of the server is in the context of the AThread param
so you should do smth like: AThread.Synchronize(DoApolloStuff);
akbAuthor Commented:
Thanks Lee.  I know this is off the thread, but I am willing to pay points for help.

I am calling my procedure with:

When I compile I get:
[Error] main.pas(866): Incompatible types: 'TThreadMethod' and 'procedure, untyped pointer or untyped parameter'

Also, can I make GetMemberDetals a function and return a result from it?

no you can't
make it a parameterless procedural handler

make one global variable - MemberID (to the owning object)
then in the GetMemberDetails procedure handle the necessary things

an example from one of my apps :

procedure TPreviewF.tcpCommExecute(AThread: TIdPeerThread);
var Header: TCommHeader;
     if not GetHeader(AThread.Connection, Header) then

     // LastCL and LastHeader are global variables

procedure TPreviewF.DoCommExecute;
var CurrThread: TidPeerThread;
    Header: TCommHeader;
     // here I assign the global variables to the procedures local variables
     HandleRequest(CurrThread.Connection, Header);
akbAuthor Commented:
Thank you, Thank you, Thank you, Thank you, Thank you!!!

I will give the points for this question to DragonSlayer as he answered the original question and I am using the Indy components.

I will post a new question in order to give you points, Lee Nover.  What do you consider to be a reasonable number for your help?

PS. is Lee Nover your real name or is it a made up name like Ben Dover or Ilene Dover?

akbAuthor Commented:
Lee Nover, please see above comment
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.