Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / October 2007

Tip: Looking for answers? Try searching our database.

How do I derive a class from Socket class.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Valerie Hough - 07 Oct 2007 00:03 GMT
Can someone please show me how to derive my own class from the Socket class?

I want to be able to pass data from the created client socket to the
AcceptConnection handler in the Socket server class, but the Socket class
has no available data store that I can use.

Thanks in advance.
Peter Duniho - 07 Oct 2007 04:37 GMT
> Can someone please show me how to derive my own class from the Socket class?
>
> I want to be able to pass data from the created client socket to the
> AcceptConnection handler in the Socket server class, but the Socket class
> has no available data store that I can use.

Typically this is done by creating some kind of container class that
includes the Socket reference and any associated data.  Then you pass an
initialized instance of _that_ as your state parameter for the async
method.  The callback method can then get the Socket instance and any
other necessary data from the container class instance.

That said, the Socket class isn't sealed.  So deriving a new class from
it is as simple as:

    class MySocket : Socket
    {
        // my specialized data here
    }

I don't see the point, but you could certainly do that.

Pete

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.