From cbbe84bec3aca732a890feea74ceef6eeee70d4e Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 09:58:01 +0000 Subject: Utilisateur : Fcolin Date : 14/01/05 Heure : 19:01 Archivé dans $/CSharp/Ivy Commentaire: remove TcpClient & MyTCpClient use directly Socket (vss 20) --- CSharp/Ivy/IvyPPC/IvyClient.cs | 43 +++++++----------------------------------- 1 file changed, 7 insertions(+), 36 deletions(-) (limited to 'CSharp/Ivy/IvyPPC/IvyClient.cs') diff --git a/CSharp/Ivy/IvyPPC/IvyClient.cs b/CSharp/Ivy/IvyPPC/IvyClient.cs index 23c65bb..37a9fde 100644 --- a/CSharp/Ivy/IvyPPC/IvyClient.cs +++ b/CSharp/Ivy/IvyPPC/IvyClient.cs @@ -15,36 +15,6 @@ namespace IvyBus using System.Net.Sockets; using System.Configuration; - /// A private Class for the the peers on the bus. - /// - internal class MyTcpClient : TcpClient - { - public IPAddress RemoteAddress - { - get - { - IPEndPoint ep = (IPEndPoint)Client.RemoteEndPoint; - return ep.Address; - } - - } - public int RemotePort - { - get - { - IPEndPoint ep = (IPEndPoint)Client.RemoteEndPoint; - return ep.Port; - } - - } - public MyTcpClient(string host,int port):base(host,port) - { - } - public MyTcpClient(Socket sock) - { - Client = sock; - } - } /// A Class for the the peers on the bus. /// /// @@ -91,7 +61,7 @@ namespace IvyBus { get { - IPHostEntry hostInfo = Dns.GetHostByAddress(socket.RemoteAddress); + IPHostEntry hostInfo = Dns.GetHostByAddress(((IPEndPoint)socket.RemoteEndPoint).Address); return hostInfo.HostName; } @@ -100,7 +70,7 @@ namespace IvyBus { get { - return socket.RemotePort; + return ((IPEndPoint)socket.RemoteEndPoint).Port; } } @@ -128,7 +98,7 @@ namespace IvyBus private static int clientSerial = 0; /* an unique ID for each IvyClient */ private Ivy bus; - private MyTcpClient socket; + private Socket socket; private StreamWriter out_stream; private StreamReader in_stream; private Hashtable regexp_in; @@ -145,7 +115,7 @@ namespace IvyBus // protected variables internal String appName; - internal IvyClient(Ivy bus, MyTcpClient socket) + internal IvyClient(Ivy bus, Socket socket) { regexp_in = Hashtable.Synchronized(new Hashtable()); regexp_text = Hashtable.Synchronized(new Hashtable()); @@ -154,8 +124,9 @@ namespace IvyBus this.bus = bus; this.socket = socket; clientKey = clientSerial++; - out_stream = new StreamWriter(socket.GetStream(),System.Text.Encoding.ASCII); - in_stream = new StreamReader(socket.GetStream(),System.Text.Encoding.ASCII); + NetworkStream net_stream = new NetworkStream( socket ); + out_stream = new StreamWriter(net_stream,System.Text.Encoding.ASCII); + in_stream = new StreamReader(net_stream,System.Text.Encoding.ASCII); // sends our ID, whether we initiated the connexion or not // the ID is the couple "host name,application Port", the host name // information is in the socket itself, the port is not known if we -- cgit v1.1