|
다음 소스에서 에러가 발생하는군요.
포트가 이미 열려 있을 경우 에러를 발생시키고 Stop이 되어야하는데
시작하는중에서 멈춰있습니다. 다시 uninstall하면 실패 또 install해도 실패입니다.
이러한 이유가 발생하는 원인이 뭔지 잘 모르겠네요..미칠거 같습니다.
좀 도와주십시오. 아래에 코드가 있습니다.
//---------------------------------------------------------------------------
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TtestV *testV;
//---------------------------------------------------------------------------
__fastcall TtestV::TtestV(TComponent* Owner)
: TService(Owner)
{
}
TServiceController __fastcall TtestV::GetServiceController(void)
{
return (TServiceController) ServiceController;
}
void __stdcall ServiceController(unsigned CtrlCode)
{
testV->Controller(CtrlCode);
}
//---------------------------------------------------------------------------
void __fastcall TtestV::ServiceStart(TService *Sender, bool &Started)
{
try {
ServerSocket1->Port=4444;
ServerSocket1->ServerType=stNonBlocking;
ServerSocket1->Active=true;
}
catch (ESocketError &e) {
ShowMessage (e.Message);
Started=false;
return;
}
Started=true;
}
//---------------------------------------------------------------------------
void __fastcall TtestV::ServiceStop(TService *Sender, bool &Stopped)
{
ServerSocket1->Active=false;
Stopped=true;
}
//---------------------------------------------------------------------------
void __fastcall TtestV::ServiceExecute(TService *Sender)
{
while (!Terminated)
ServiceThread->ProcessRequests(false);
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <SysUtils.hpp>
#include <Classes.hpp>
#include <SvcMgr.hpp>
#include <vcl.h>
#include <ScktComp.hpp>
//---------------------------------------------------------------------------
class TtestV : public TService
{
__published: // IDE-managed Components
TServerSocket *ServerSocket1;
void __fastcall ServiceStart(TService *Sender, bool &Started);
void __fastcall ServiceStop(TService *Sender, bool &Stopped);
void __fastcall ServiceExecute(TService *Sender);
private: // User declarations
public: // User declarations
__fastcall TtestV(TComponent* Owner);
TServiceController __fastcall GetServiceController(void);
friend void __stdcall ServiceController(unsigned CtrlCode);
};
//---------------------------------------------------------------------------
extern PACKAGE TtestV *testV;
//---------------------------------------------------------------------------
#endif
|