Wednesday, November 10, 2004

Derived TcpClient classes used on the server side

The TcpClient class is built on top of the System.Net.Sockets.Socket class and takes care of the details of transferring data. It doesn't cover all the features of the Socket class. For example, RemoteEndPoint (used to identify a remote socket).

To access features of the Socket class not exposed by the protocol classes, you must use the underlying Socket class. TcpClient uses the Client property to identify the underlying Socket. However this property is protected. So you need to derive a class from TcpClient to access the Client property. On the other hand, TcpListener.AcceptClient returns a TcpClient object. So the derived TcpClient class can not be used on the server side directly. The following code shows you how to get around this.

public class TcpTalker : TcpClient
{
private RemoteEndPoint remotePoint = null;
public TcpTalker(Socket socket)
{
this.Client = socket;
remotePoint = this.Client.RemoteEndPoint;
}
......
}
......
// use the derived class on the server side
// tcpl is a TcpListener object
TcpTalker tlk = new TcpTalker(tcpl.AcceptSocket());

2 Comments:

At 5:13 PM, Blogger Unknown said...

louis vuitton outlet, ugg boots, ray ban sunglasses, oakley sunglasses, louis vuitton outlet, longchamp pas cher, prada outlet, polo ralph lauren outlet, nike outlet, chanel handbags, louboutin outlet, longchamp outlet, louis vuitton, nike air max, cheap oakley sunglasses, longchamp outlet, jordan shoes, louis vuitton, nike free, tiffany and co, tory burch outlet, prada handbags, replica watches, nike roshe run, longchamp, louboutin, air max, ralph lauren pas cher, christian louboutin outlet, replica watches, louis vuitton, nike air max, kate spade outlet, louboutin pas cher, nike free, oakley sunglasses, sac longchamp, oakley sunglasses, polo ralph lauren outlet, louboutin shoes, uggs on sale, ray ban sunglasses, ray ban sunglasses, burberry, gucci outlet, oakley sunglasses, tiffany jewelry, ugg boots, air jordan pas cher, michael kors

 
At 5:20 PM, Blogger Unknown said...

montre pas cher, moncler outlet, moncler, karen millen, moncler, supra shoes, ugg pas cher, wedding dresses, swarovski, moncler, sac louis vuitton pas cher, doudoune canada goose, moncler, louis vuitton, pandora charms, canada goose, ugg,uggs,uggs canada, swarovski crystal, marc jacobs, hollister, moncler, toms shoes, louis vuitton, ugg boots uk, louis vuitton, canada goose uk, coach outlet, louis vuitton, moncler, canada goose, pandora charms, links of london, moncler, canada goose, canada goose outlet, pandora jewelry, juicy couture outlet, canada goose, thomas sabo, juicy couture outlet, pandora jewelry, bottes ugg, canada goose outlet, ugg,ugg australia,ugg italia, replica watches

 

Post a Comment

<< Home