🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #93

Cannot convert OnUDPException handler to TIdUDPExceptionEvent

#93
From: 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
Technical Details
Message-ID: <e244020a-91d7-4296-98a9-0779f6d0e6bf@y21g2000hsf.googlegroups.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!y21g2000hsf.googlegroups.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,bd9e2ca46960059a,start
X-Google-Attributes: gid11508e,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!y21g2000hsf.googlegroups.com!not-for-mail
From: jesse <jesse@goerz.us>
Newsgroups: borland.public.cppbuilder.internet.socket
Subject: Cannot convert OnUDPException handler to TIdUDPExceptionEvent
Date: Tue, 29 Apr 2008 10:36:35 -0700 (PDT)
Organization: http://groups.google.com
Lines: 51
Message-ID: <e244020a-91d7-4296-98a9-0779f6d0e6bf@y21g2000hsf.googlegroups.com>
NNTP-Posting-Host: 128.217.77.16
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Trace: posting.google.com 1209490596 24950 127.0.0.1 (29 Apr 2008 17:36:36 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Tue, 29 Apr 2008 17:36:36 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: y21g2000hsf.googlegroups.com; posting-host=128.217.77.16; 
 posting-account=6q83zQoAAABx03s3-G4Ic6LwTjCEzh3b
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14) 
 Gecko/20080404 Firefox/2.0.0.14,gzip(gfe),gzip(gfe)