Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old October 7th, 2004, 12:36 PM
Registered User
 
Join Date: Oct 2004
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Derive TcpClient

Hi there

I try to have a specialized TcpClient. Therefore MyTcpClient derives from TcpClient. Now, i thougt the following is possible:

MyTcpClient client = (MyTcpClient) listener.AcceptTcpClient();

But the cast fails. Any idea why or a way to go around the problem?

Thank and cheers
Simon

Visit: http://pubwww.fhzh.ch/~sgysi
Reply With Quote
  #2 (permalink)  
Old October 8th, 2004, 05:54 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 453
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

What error do you get, syntax-wise your code is correct.
Reply With Quote
  #3 (permalink)  
Old October 8th, 2004, 11:02 AM
Registered User
 
Join Date: Oct 2004
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

Compiles, but throws a invalid vast exception.

Simon

Reply With Quote
  #4 (permalink)  
Old October 10th, 2004, 12:59 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 453
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

I tried it and found the same problem, although you can use classes derived from TcpClient on the client side.
Reply With Quote
  #5 (permalink)  
Old October 11th, 2004, 06:18 PM
Kep Kep is offline
Authorized User
 
Join Date: Aug 2003
Location: Melbourne, VIC, Australia.
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The only way you can get this to work is to use AcceptSocket().

try...
Code:
MyTcpClient client = new MyTcpClient(listener.AcceptSocket());
This should do what you need.

Kep.
Reply With Quote
  #6 (permalink)  
Old October 11th, 2004, 11:01 PM
Registered User
 
Join Date: Oct 2004
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank all!
Simon

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
can we able to derive a script from mdb mrleokarthik Pro VB 6 0 November 28th, 2003 07:49 AM



All times are GMT -4. The time now is 05:33 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.