I am receiving 3144 bytes of data through TCP/IP socket during debug mode, but in excecution 1023 bytes were received. Why isn't the remaining data read?
IPEndPoint ipEnd = new IPEndPoint(ipAdd, ipPort);
Socket soc = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
soc.Connect(ipEnd);
byte[] sendData = Encoding.ASCII.GetBytes("msg");
soc.Send(sendData);
int byteLen = 4*1024;
byte[] RecData = new byte[byteLen];
int DataLen = soc.Receive(RecData, 0, RecData.Length, SocketFlags.None);// Here I placed breakpoint
string str = Encoding.ASCII.GetString(RecData, 0, DataLen);
MessageBox.WriteLine(str);
soc.Close();
On step by step debug I get DataLen
as 3144 bytes and it works properly. During excecution, though, I am receiving DataLen
as 1023 bytes. Why does this happen? I need to print the received data str
in either a MessageBox
or TextBox
.