ramesh p

ramesh p

  • NA
  • 109
  • 0

How to recieve more than 1024 bytes of data from tcpclient?

Feb 15 2010 1:11 AM

I have created 2 applications. 1) TCPServer 2) TCPClient. I am sending more than  2 kb of data from TCPClient. TCPServer recieving only 1024 bytes. But, i want to recieve up to 5 to 6 kb of data. How to do it?
Here i am written my code. See below....
public
class SocketPacket
{
// Constructor which takes a Socket and a client number
public SocketPacket(System.Net.Sockets.Socket socket, int clientNumber)
{
m_currentSocket = socket;
m_clientNumber = clientNumber;
}
public System.Net.Sockets.Socket m_currentSocket;
public int m_clientNumber;
// Buffer to store the data sent by the client
public byte[] dataBuffer = new byte[8192];
}
private void OnDataReceivedFromClients(IAsyncResult asyn)
{
SocketPacket socketData = (SocketPacket)asyn.AsyncState;

try
{
int iRx = socketData.m_currentSocket.EndReceive(asyn);
char[] chars = new char[iRx + 1];
System.Text.Decoder d = System.Text.Encoding.UTF8.GetDecoder();
int charLen = d.GetChars(socketData.dataBuffer, 0, iRx, chars, 0);
socketData.dataBuffer.GetLength(0);
String D = new String(chars);
string Data = Encoding.ASCII.GetString(socketData.dataBuffer, 0, socketData.dataBuffer.Length - 1);
}

Answers (1)