Changeset 907
- Timestamp:
- Aug 11, 2010, 7:37:01 AM (14 years ago)
- Location:
- BMXNET_RPMS_dotNET_UTILITIES-BMX/trunk/cs/bmx_0200scr/BMX2/BMXNet
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
BMXNET_RPMS_dotNET_UTILITIES-BMX/trunk/cs/bmx_0200scr/BMX2/BMXNet/BMXNet.csproj
r822 r907 52 52 <ConfigurationOverrideFile> 53 53 </ConfigurationOverrideFile> 54 <DefineConstants> DEBUG</DefineConstants>54 <DefineConstants>TRACE;DEBUG</DefineConstants> 55 55 <DocumentationFile>bmxnet.xml</DocumentationFile> 56 56 <DebugSymbols>true</DebugSymbols> … … 73 73 <ConfigurationOverrideFile> 74 74 </ConfigurationOverrideFile> 75 <DefineConstants> 76 </DefineConstants> 75 <DefineConstants>TRACE;DEBUG</DefineConstants> 77 76 <DocumentationFile>bmxnet.xml</DocumentationFile> 78 77 <DebugSymbols>true</DebugSymbols> -
BMXNET_RPMS_dotNET_UTILITIES-BMX/trunk/cs/bmx_0200scr/BMX2/BMXNet/BMXNetLib.cs
r852 r907 846 846 NetworkStream ns = tcpClient.GetStream(); 847 847 848 int nTimeOut = this.m_nReceiveTimeout; 849 int nCnt = 0; 850 int nTimeElapsed = 0; 848 int nTimeOut = this.m_nReceiveTimeout; //timeout 849 int nCnt = 0; //number of times trying to get a message from the client 850 int nTimeElapsed = 0; //compare with timeout; increment 50 ms everytime. 851 851 while (ns.DataAvailable == false) 852 852 { … … 861 861 862 862 Debug.Assert(ns.DataAvailable == true); 863 if (ns.DataAvailable == false) 863 if (ns.DataAvailable == false) //if still false, then we timed out. 864 864 { 865 865 this.CloseConnection(); … … 868 868 } 869 869 870 byte[] bReadBuffer = new byte[1024]; 871 string sReadBuffer = ""; 872 StringBuilder sbAll = new StringBuilder("", 1024); 870 byte[] bReadBuffer = new byte[1024]; //byte buffer 871 string sReadBuffer = ""; //string buffer 872 StringBuilder sbAll = new StringBuilder("", 1024); //string builder 873 873 int numberOfBytesRead = 0; 874 874 875 875 // Incoming message may be larger than the buffer size. 876 876 877 bool bFinished = false; 878 int nFind = -1; 879 bool bStarted = false; 880 int lpBuf = 0; 881 string sError = ""; 882 string sAppError = ""; 877 bool bFinished = false; //finished reading? 878 int nFind = -1; //Position of $C(4) (End of Transmission) 879 bool bStarted = false; //Is the buffer started? 880 int lpBuf = 0; //? 881 string sError = ""; //? 882 string sAppError = ""; //? 883 883 do 884 884 { 885 numberOfBytesRead = ns.Read(bReadBuffer, 0, bReadBuffer.Length); 886 if ((numberOfBytesRead == 1)&&(bStarted == false)) 885 numberOfBytesRead = ns.Read(bReadBuffer, 0, bReadBuffer.Length); // read 1024 characters 886 if ((numberOfBytesRead == 1)&&(bStarted == false)) // if only one byte read, try again in 15 ms 887 887 { 888 888 Thread.Sleep(15); 889 numberOfBytesRead += ns.Read(bReadBuffer,1, bReadBuffer.Length-1); 889 numberOfBytesRead += ns.Read(bReadBuffer,1, bReadBuffer.Length-1); //skip the first one of course 890 890 //Debug.Write("ReceiveString waiting for data...\n"); 891 891 } 892 if (bStarted == false) 892 if (bStarted == false) //if this is the first transmission process error info 893 893 { 894 894 //Process error info at beginning of returned string … … 910 910 } 911 911 912 nFind = FindChar(bReadBuffer, (char) 4); 913 if (nFind > -1) 914 bFinished = true; 915 Debug.Assert(numberOfBytesRead > -1); 912 nFind = FindChar(bReadBuffer, (char) 4); //find end of transmission chracter 913 if (nFind > -1) // if found 914 bFinished = true; //then we are finished 915 Debug.Assert(numberOfBytesRead > -1); // this must be true 916 916 sReadBuffer = m_Encoding.GetString(bReadBuffer, lpBuf, numberOfBytesRead); 917 917 lpBuf = 0; 918 918 if (nFind > -1) 919 919 { 920 sbAll.Append(sReadBuffer, 0, numberOfBytesRead -1); 920 //sbAll.Append(sReadBuffer, 0, numberOfBytesRead -1); //utf8 921 sbAll.Append(sReadBuffer, 0, sReadBuffer.Length - 1); 921 922 } 922 923 else
Note:
See TracChangeset
for help on using the changeset viewer.