dotgnu-libs-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-libs-commits] CVS: dotgnu-base/DotGNU/Net/Sockets NetworkStream.


From: Peter Minten <address@hidden>
Subject: [Dotgnu-libs-commits] CVS: dotgnu-base/DotGNU/Net/Sockets NetworkStream.cs,1.3,1.4 Socket.cs,1.3,1.4
Date: Sat, 03 Aug 2002 07:13:58 -0400

Update of /cvsroot/dotgnu-libs/dotgnu-base/DotGNU/Net/Sockets
In directory subversions:/tmp/cvs-serv4727/DotGNU/Net/Sockets

Modified Files:
        NetworkStream.cs Socket.cs 
Log Message:
Weekly update


Index: NetworkStream.cs
===================================================================
RCS file: /cvsroot/dotgnu-libs/dotgnu-base/DotGNU/Net/Sockets/NetworkStream.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** NetworkStream.cs    28 Jul 2002 15:56:34 -0000      1.3
--- NetworkStream.cs    3 Aug 2002 11:13:55 -0000       1.4
***************
*** 46,51 ****
                : base (NetworkStream.connectSocket(address, port)) {}
        
-       //DotGNU Stuff
-       
        //For the String stuff the number of chars received/send is 
buffer.Length
        //I keep the return type void so that programmers don't get confused
--- 46,49 ----
***************
*** 56,74 ****
        /// <summary>Read method using unicode, 
        ///   reads until no more data is available.</summary>
        /// <param name="buffer">The buffer to place the data in.</param>
!       public void Read (String buffer)
        {
!               Stream.Read(this, buffer);
!               return;
        }
        
        /// <summary>Read method using the specified encoding, 
        ///   reads until no more data is available.</summary>
        /// <param name="buffer">The buffer to place the data in.</param>
        /// <param name="encoding">The encoding to use.</param>
!       public void Read (String buffer, Encoding encoding)
        {
!               Stream.Read(this, buffer, encoding);
!               return;
        }
  
--- 54,72 ----
        /// <summary>Read method using unicode, 
        ///   reads until no more data is available.</summary>
+       /// <returns>The number of bytes read.</returns>
        /// <param name="buffer">The buffer to place the data in.</param>
!       public int Read (String buffer)
        {
!               return Stream.Read(this, buffer);
        }
        
        /// <summary>Read method using the specified encoding, 
        ///   reads until no more data is available.</summary>
+       /// <returns>The number of bytes read.</returns>
        /// <param name="buffer">The buffer to place the data in.</param>
        /// <param name="encoding">The encoding to use.</param>
!       public int Read (String buffer, Encoding encoding)
        {
!               return Stream.Read(this, buffer, encoding);
        }
  
***************
*** 97,116 ****
        
        /// <summary>Read operator for byte[], reads until b is full.</summary>
        /// <param name="a">The stream to work on.</param>
        /// <param name="b">The buffer to put the data in.</param>
!       public static Stream operator>> (System.IO.Stream a, byte[] b)
        {
!               a.Read(b, 0, b.Length);
!               return null;
        }
                                  
        /// <summary>Read operator for String, 
        ///   reads until no more data is available.</summary>
        /// <param name="a">The stream to work on.</param>
        /// <param name="b">The buffer to put the data in.</param>      
!       public static Stream operator>> (System.IO.Stream a, String b)
        {
!               Stream.Read(a, b);
!               return null;
        }
        
--- 95,114 ----
        
        /// <summary>Read operator for byte[], reads until b is full.</summary>
+       /// <returns>The number of bytes read.</returns>
        /// <param name="a">The stream to work on.</param>
        /// <param name="b">The buffer to put the data in.</param>
!       public static long operator>> (System.IO.Stream a, byte[] b)
        {
!               return a.Read(b, 0, b.Length);
        }
                                  
        /// <summary>Read operator for String, 
        ///   reads until no more data is available.</summary>
+       /// <returns>The number of bytes read.</returns>
        /// <param name="a">The stream to work on.</param>
        /// <param name="b">The buffer to put the data in.</param>      
!       public static long operator>> (System.IO.Stream a, String b)
        {
!               return Stream.Read(a, b);
        }
        
***************
*** 118,134 ****
        /// <param name="a">The stream to work on.</param>
        /// <param name="b">The buffer to get the data from.</param>
!       public static Stream operator<< (System.IO.Stream a, byte[] b)
        {
                a.Write(b, 0, b.Length);
!               return null;
        }
  
        /// <summary>Write operator for String.</summary>
        /// <param name="a">The stream to work on.</param>
        /// <param name="b">The buffer to get the data from.</param>    
!       public static Stream operator<< (System.IO.Stream a, String b)
        {
                Stream.Write(a, b);
!               return null;
        }        
  
--- 116,133 ----
        /// <param name="a">The stream to work on.</param>
        /// <param name="b">The buffer to get the data from.</param>
!       public static void operator<< (System.IO.Stream a, byte[] b)
        {
                a.Write(b, 0, b.Length);
!               return;
        }
  
        /// <summary>Write operator for String.</summary>
+       /// <returns>The number of bytes send.</returns>
        /// <param name="a">The stream to work on.</param>
        /// <param name="b">The buffer to get the data from.</param>    
!       public static void operator<< (System.IO.Stream a, String b)
        {
                Stream.Write(a, b);
!               return;
        }        
  
***************
*** 141,146 ****
                return returnval;
        }
!       
  }; // class NetworkStream
  
  }; // namespace DotGNU.Net.Sockets 
--- 140,147 ----
                return returnval;
        }
! 
  }; // class NetworkStream
+ 
+ class dgNetworkStream : DotGNU.Net.Sockets.NetworkStream {}; //Alias
  
  }; // namespace DotGNU.Net.Sockets 

Index: Socket.cs
===================================================================
RCS file: /cvsroot/dotgnu-libs/dotgnu-base/DotGNU/Net/Sockets/Socket.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** Socket.cs   28 Jul 2002 15:56:34 -0000      1.3
--- Socket.cs   3 Aug 2002 11:13:55 -0000       1.4
***************
*** 15,19 ****
   *
   * You should have received a copy of the GNU Lesser General Public License
!  * along with this program; if not, write to the Free Software
   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   */
--- 15,19 ----
   *
   * You should have received a copy of the GNU Lesser General Public License
!  * aint with this program; if not, write to the Free Software
   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   */
***************
*** 31,34 ****
--- 31,35 ----
  using DotGNU.Threading;
  
+ //TODO: Document this class
  public class Socket : System.Net.Sockets.Socket 
  {
***************
*** 61,85 ****
        //Easy Receive methods
        //For the String stuff the number of chars received is buffer.Length
!       //I keep the return type void so that programmers don't get confused
!       //between bytes received and chars received
!       public void Receive(String buffer)
        {
!               Receive(buffer, Encoding.Unicode, SocketFlags.None);
!               return;
        }
  
!       public void Receive(String buffer, SocketFlags socketFlags)
        {
!               Receive(buffer, Encoding.Unicode, socketFlags);
!               return;
        }
  
!       public void Receive(String buffer, Encoding encoding)
        {
!               Receive(buffer, encoding, SocketFlags.None);
!               return;
        }
  
!       public void Receive(String buffer, Encoding encoding, SocketFlags 
socketFlags)
        {
                buffer = ""; //Clean buffer
--- 62,82 ----
        //Easy Receive methods
        //For the String stuff the number of chars received is buffer.Length
!       //Returns the number of bytes(!) received.
!       public int Receive(String buffer)
        {
!               return Receive(buffer, Encoding.Unicode, SocketFlags.None);
        }
  
!       public int Receive(String buffer, SocketFlags socketFlags)
        {
!               return Receive(buffer, Encoding.Unicode, socketFlags);
        }
  
!       public int Receive(String buffer, Encoding encoding)
        {
!               return Receive(buffer, encoding, SocketFlags.None);
        }
  
!       public int Receive(String buffer, Encoding encoding, SocketFlags 
socketFlags)
        {
                buffer = ""; //Clean buffer
***************
*** 88,91 ****
--- 85,89 ----
                char[] cbuf = new char[514]; //Stay on the safe side with size 
estimations
                int charsread;
+               int bytesread = 0;
                String tbuffer;
  
***************
*** 102,134 ****
                        buffer += tbuffer;
  
                        if (bytesreceived < 1024)
!                               return;
  
                } while (true); //Infinite loop if it wasn't for that return 
statement
-       }
  
!       //Easy send methods
!       public void Send(String buffer)
!       {
!               Send(Encoding.Unicode.GetBytes(buffer), SocketFlags.None);
!               return;
        }
  
!       public void Send(String buffer, SocketFlags socketFlags)
        {
!               Send(Encoding.Unicode.GetBytes(buffer), socketFlags);
!               return;
        }
  
!       public void Send(String buffer, Encoding encoding)
        {
!               Send(buffer, encoding, SocketFlags.None);
!               return;
        }
  
!       public void Send(String buffer, Encoding encoding, SocketFlags 
socketFlags)
!       {
!               Send(encoding.GetBytes(buffer), socketFlags);
!               return;
        }
  
--- 100,162 ----
                        buffer += tbuffer;
  
+                       bytesread += bytesreceived;
+ 
                        if (bytesreceived < 1024)
!                               return bytesread;
  
                } while (true); //Infinite loop if it wasn't for that return 
statement
  
!               return 0; //Useless, but saves a warning
        }
  
!       //Easy send methods
!       public int Send(String buffer)
        {
!               return Send(buffer, Encoding.Unicode, SocketFlags.None);
        }
  
!       public int Send(String buffer, SocketFlags socketFlags)
        {
!               return Send(buffer, Encoding.Unicode, socketFlags);
        }
  
!       public int Send(String buffer, Encoding encoding)
!       {
!               return Send(buffer, encoding, SocketFlags.None);
!       }
! 
!       public int Send(String buffer, Encoding encoding, SocketFlags 
socketFlags)
!       {
!               int charssend = 0;
!               char[] cbuf = new char[510]; //Stay on the safe side with size 
estimations
!               byte[] bbuf = new byte[1024];
!               int charptr = 0;
!               int bytesencoded;
!               int bytessend;
!               int totalbytessend;
!               
!               while (true)
!               {
!                       if ((buffer.Length - charptr) >= 510)
!                       {
!                               bytesencoded = encoding.GetBytes(buffer, 
charptr, 510, bbuf, 0);
!                               charptr += 510; //510 chars are encoded
!                       }
!                       else
!                       {       
!                               int foo = buffer.Length - charptr;
!                               bytesencoded = encoding.GetBytes(buffer, 
charptr, foo, bbuf, 0);
!                               charptr += foo;
!                       }
!                       
!                       bytessend = Send(bbuf, 0, bytesencoded, socketFlags);
!                       
!                       totalbytessend += bytessend;
!                       
!                       if (charptr == buffer.Length)
!                               return totalbytessend; //Send operation done, 
return.
!               }
!       
!               return 0; //Useless, but saves a warning
        }
  
***************
*** 263,294 ****
  
        //Receive operator
!       public static void operator>> (Socket sock, String str)
        {
!               sock.Receive(str);
!               return;
        }
  
        //Receive operator
!       public static void operator>> (Socket sock, byte[] bucket)
        {
!               sock.Receive(bucket);
!               return;
        }
  
        //Send operator
!       public static void operator<< (Socket sock, String str)
        {
!               sock.Send(str);
!               return;
        }
  
        //Send operator
!       public static void operator<< (Socket sock, byte[] bucket)
        {
!               sock.Send(bucket);
!               return;
        }
  }; // class Socket
  
  
  }; // namespace DotGNU.Net.Sockets 
--- 291,319 ----
  
        //Receive operator
!       public static int operator>> (Socket sock, String str)
        {
!               return sock.Receive(str);
        }
  
        //Receive operator
!       public static int operator>> (Socket sock, byte[] bucket)
        {
!               return sock.Receive(bucket);
        }
  
        //Send operator
!       public static int operator<< (Socket sock, String str)
        {
!               return sock.Send(str);
        }
  
        //Send operator
!       public static int operator<< (Socket sock, byte[] bucket)
        {
!               return sock.Send(bucket);
        }
  }; // class Socket
  
+ class dgSocket : DotGNU.Net.Sockets.Socket {}; //Alias
  
  }; // namespace DotGNU.Net.Sockets 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]