Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Server Socket Queues

Posted on 2002-04-15
15
Medium Priority
?
763 Views
Last Modified: 2011-10-03
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.
0
Comment
Question by:akb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
15 Comments
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 6944731
>>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
0
 
LVL 13

Author Comment

by:akb
ID: 6946351
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.
0
 
LVL 14

Accepted Solution

by:
DragonSlayer earned 400 total points
ID: 6946650
Have you tried the Indy components? (they come with Delphi6 and can also be downloaded from http://www.nevrona.com/indy/)

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


HTH
DragonSlayer.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 13

Author Comment

by:akb
ID: 6946832
Thanks DragonSlayer.  The Indy components look like they may be useful.  I have downloaded them and will try them out shortly.
0
 
LVL 2

Expert Comment

by:freshman3k
ID: 6948927
Hello!

This component is what you need:
http://overbyte.alexid.fr/frame_index.html

Good Luck!


0
 
LVL 13

Author Comment

by:akb
ID: 6949283
Thanks freshman3k.  I'll take a look at these components as well.
0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 6949368
if you're going to use indy then take a look at some of my helper functions @ http://lee.nover.has.his.evilside.org/isapi/pas2html.dll/pas2html?File=/delphi/MiscFiles/vn_common/
0
 
LVL 13

Author Comment

by:akb
ID: 6949374
Thanks Lee Nover.
0
 
LVL 13

Author Comment

by:akb
ID: 6949433
Thanks Lee Nover.
0
 
LVL 13

Author Comment

by:akb
ID: 6949688
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
Error:3200
Invalid work area

I am happy to increase the points for help on this problem.
0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 6949966
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);
0
 
LVL 13

Author Comment

by:akb
ID: 6952207
Thanks Lee.  I know this is off the thread, but I am willing to pay points for help.

I am calling my procedure with:
AThread.Synchronize(GetMemberDetails(MemberID));

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?

0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 6952225
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;
begin
     if not GetHeader(AThread.Connection, Header) then
        Exit;

     // LastCL and LastHeader are global variables
     LastCL:=TCrossLink(AThread.Data);
     LastHeader:=Header;
     AThread.Synchronize(DoCommExecute);
end;

procedure TPreviewF.DoCommExecute;
var CurrThread: TidPeerThread;
    Header: TCommHeader;
begin
     // here I assign the global variables to the procedures local variables
     CurrThread:=LastCL.AThread;
     Header:=LastHeader;
     HandleRequest(CurrThread.Connection, Header);
end;
0
 
LVL 13

Author Comment

by:akb
ID: 6952255
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?

0
 
LVL 13

Author Comment

by:akb
ID: 6958496
Lee Nover, please see above comment
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question