🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.socket
1 messages
1 total messages Started by jesse Tue, 29 Apr 2008 17:36
Cannot convert OnUDPException handler to TIdUDPExceptionEvent
#93
Author: jesse
Date: Tue, 29 Apr 2008 17:36
50 lines
2930 bytes
I'm using a TIdUDPServer and I have the following code:

__fastcall InputThread::InputThread(bool CreateSuspended,
  char* ipAddress,
  int portNumber)
: TThread(CreateSuspended)
{
  this->ipAddress = ipAddress;
  udpServer = new TIdUDPServer(NULL);
  udpServer->DefaultPort = portNumber;
  udpServer->BroadcastEnabled = false;
  udpServer->ThreadedEvent = true;  // handle synchronization manually
  udpServer->OnUDPRead = udpReadHandler;
  udpServer->OnStatus = udpStatusHandler;  // TODO
  udpServer->OnUDPException = udpExceptionHandler; // TODO
 // FIXME: Why is this cast to the Event type necessary?
 //udpServer->OnUDPException = (TIdUDPExceptionEvent)
&udpExceptionHandler;
  udpServer->Active = true;
...
}

My udpExceptionHandler looks like this in the header file:

void __fastcall udpExceptionHandler(TObject *Sender,
  TIdSocketHandle *ABinding,
  const AnsiString AMessage,
  const TClass AExceptionClass);

And here is the implementation:
void __fastcall InputThread::udpExceptionHandler(TObject *Sender,
  TIdSocketHandle *ABinding,
  const AnsiString AMessage,
  const TClass AExceptionClass)
{
	// TODO
}

Compiling this I get the following error:
[BCC32 Error] InputThread.cpp(71): E2034 Cannot convert 'void
(_fastcall * (_closure )(TObject *,TIdSocketHandle *,const
AnsiString,TMetaClass * const))(TObject *,TIdSocketHandle *,const
AnsiString,TMetaClass * const)' to 'TIdUDPExceptionEvent'

I can cast the function to a TIdUDPExceptionEvent and it compiles
without the error.  The example code is above, just commented out.
I'm not sure if I have the right signature or if am I missing
something?  Is it Ok to cast this to the proper event type?

Jesse
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads