Deriving a class from Socket.

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.
 
A

Anthony Jones

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.
 
V

Valerie Hough

Thanks for the response.

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

Thanks
 
I

ivar

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, ... .
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top