Deriving a class from Socket.

  • Thread starter Thread starter Valerie Hough
  • Start date Start date
V

Valerie Hough

I would like to derive my own class from the Socket class so that I can pass
data from my client socket to the socket Server's OnAccept event..

I tried the syntax :
public class MySocketClass: Socket
but received a compiler error saying that there had to be arguments to the
constructor for my new class.

Any help greately appreciated.
 
Valerie Hough said:
I would like to derive my own class from the Socket class so that I can pass
data from my client socket to the socket Server's OnAccept event..

I tried the syntax :
public class MySocketClass: Socket
but received a compiler error saying that there had to be arguments to the
constructor for my new class.

Any help greately appreciated.

Unless you specifically define a default constructor C# assumes one is
implied of the form:-

public MySocketClass() : Base()

However since Socket doesn't have a parameter less constructor it fails.
 
Thanks for the response.

Does that mean if I supply parameters I can derive my own class from Socket?

Thanks
 
Hi,

Yes you can, but is it wise to derrive from socket ? Is it wise to relay on
socket class ?

For example if you use TCP, isn't is wiser to relay on stream like
NetworkStream ?
This keeps all doors open, you can implement SSL later if needed, ... .
 
Back
Top