private string strBuffer = ""; //< String version of the buffer.

        #endregion Fields

        #region Constructors

        /**
         * Constructor for ConnectionState.
         *
         * @param newConnection
         *  The TcpClient to base the ConnectionState object on.
         * @param readLength
         *  The amount of data to attempt to read on each read.
         */
        public ConnectionState(Sockets.TcpClient newConnection, int readLength)
        {
            bufferLength = readLength;
            clientConnection = newConnection;
            clientStream = newConnection.GetStream();
            ClearBuffer();
        }
Esempio n. 2
0
 /**
  * Writes data to a client.
  *
  * @param writeConnection
  *  The client to write data to.
  * @param sendData
  *  The data to send to the client.
  */
 public void WriteData(Sockets.TcpClient writeConnection, string sendData)
 {
     try {
         byte[] arrWrite = Utils.StrToBytes(sendData + delimiterString);
         writeConnection.LingerState = new Sockets.LingerOption(true, 2);
         if(writeConnection.GetStream().CanWrite) writeConnection.GetStream().BeginWrite(arrWrite, 0, arrWrite.Length, WriteCallback, writeConnection);
     }catch(System.Exception writeEx){
         Out.Logger.WriteOutput("Could not write to client: " + writeEx.Message + ".");
     }
 }