看不懂的代码,高手来说说
凋零的老树 2016-09-12 11:29:58 public static bool Execute(string ip, int port, int sendTimeout, int receiveTimeout, string jsonSend, ref string jsonRec, byte mti1, byte mti2)
{
for (int i = 0; i < 1; i++)
{
TcpClient client = null;
try
{
int num2 = 0x100000;
byte[] bytes = Encoding.UTF8.GetBytes(jsonSend);
client = new TcpClient {
SendBufferSize = num2,
ReceiveBufferSize = num2
};
client.Connect(ip, Convert.ToInt32(port));
using (NetworkStream stream = client.GetStream())
{
byte[] buffer3;
bool flag2;
stream.WriteTimeout = sendTimeout;
stream.ReadTimeout = receiveTimeout;
stream.Write(bytes, 0, bytes.Length);
bytes = null;
int length = 0;
goto Label_010A;
Label_0092:
buffer3 = new byte[num2];
int num4 = stream.Read(buffer3, 0, buffer3.Length);
byte[] destinationArray = new byte[num4];
Array.Copy(buffer3, destinationArray, num4);
bytes = ConverterUtil.CombinByteArray(bytes, destinationArray);
byte[] buffer5 =bytes;
if (buffer5 != null)
{
buffer5 = ConverterUtil.DecodingMessageHeader(buffer5);
length = ConverterUtil.ByteArrayToInt(buffer5, 4);
if (bytes.Length >= (length + buffer5.Length))
{
goto Label_010F;
}
}
Label_010A:
flag2 = true;
goto Label_0092;
Label_010F:
if (bytes != null)
{
byte[] buffer6 = new byte[length];
Array.Copy(bytes, bytes.Length - length, buffer6, 0, length);
jsonRec = Encoding.UTF8.GetString(buffer6);
}
return true;
}
}
catch (Exception exception)
{
Thread.Sleep(0x3e8);
}
finally
{
try
{
client.Close();
}
catch
{
}
}
}
return false;
}
有两个疑问:
1.为什么要用goto,
2.为什么 for (int i = 0; i < 1; i++) 这个0到1有什么意义啊?