Inheritance...

  • Thread starter Thread starter Jan Engel Ketmig
  • Start date Start date
J

Jan Engel Ketmig

I need to Inherit TcpListener and TcpClient to get access to the protected
areas of the objects. How do I do it practically. I tried and succeeded with
the TcpListener and made a function .mAcceptTcpClient that returns a
TcpClient. I need to have my inherited version of the TcpClient returned
instead... Any thoughts?

Jan
 
I need to have my inherited version of the TcpClient returned
instead... Any thoughts?

You can't do that, unless the TcpListener provides some overridable
factory method for creating the TcpClient object.



Mattias
 
in the inherited class:

function mAcceptTcpClient() as nonStdTcpClient
return mybase.AcceptClient() ' or whatever the base interface is to
accept the new client
end function

in the calling class:

dim myTcpListener as new nonStdTcpListener() ' instanciate your modified
listener

dim myClientVersion as nonStdTcpClient = myTcpListener.mAcceptTcpClient
dim stdClientVersion as TcpClient = myTcpListener.mAcceptTcpClient()

the first example gives you your modified version of the std. TcpClient
the second gives you just the std. TcpClient.

hth,

steve
 
Back
Top