We help IT Professionals succeed at work.
Get Started

Console App Help...

-Karamja-
-Karamja- asked
on
1,151 Views
Last Modified: 2008-02-01
Hello,
 I have this code but I need some help with it

Program Project2;

{$APPTYPE CONSOLE}

Uses
  SysUtils, ScktComp;

Type
  TMyApp = Class(TObject)
    Public
      Procedure Connect(Sender: TObject; Socket: TCustomWinSocket);
      Procedure Disconnect(Sender: TObject; Socket: TCustomWinSocket);
      Procedure Receive(Sender: TObject; Socket: TCustomWinSocket);
  End;

Var
  MyApp: TMyApp; Server: TServerSocket;

Procedure TMyApp.Connect(Sender: TObject; Socket: TCustomWinSocket); Begin WriteLn('Connected.') End;
Procedure TMyApp.Disconnect(Sender: TObject; Socket: TCustomWinSocket); Begin WriteLn('Disconnected.') End;
Procedure TMyApp.Receive(Sender: TObject; Socket: TCustomWinSocket); Begin WriteLn(Socket.ReceiveText) End;

Begin
  MyApp := TMyApp.Create;
  Server := TServerSocket.Create(nil);
  Server.OnClientConnect := MyApp.Connect;
  Server.OnClientDisconnect := MyApp.Disconnect;
  Server.OnClientRead := MyApp.Receive;
  Server.Port := 6000;
  Server.Active := True;
  While True Do ReadLn;
End.

But I think the
   While True Do ReadLn;

Is blocking the ServerSocket, how can I fix this?
I will give more points but this is all I have at the mo.

Thx Karamja
Comment
Watch Question
Melih SARICA
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 19 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE