I am currently doing a file transfer project using TCP connection. However, I feel that if the file is too big for the network to handle, it will only receive the 1st packet arrived at the server and ignore the other packets waiting to be accepted. Can anyone help me and see when I have gone wrong in the codes? Thank you!
Code:
ipEnd = new IPEndPoint(IPAddress.Any, 8002);
socketServer= new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
socketServer.Bind(ipEnd);
socketServer.Listen(100);
clientSock = socketServer.Accept();
byte[] RxData = new byte[1024 * 5000];
int receivedBytesLen = clientSock.Receive(clientData);
int fileNameLen = BitConverter.ToInt32(clientData, 0);
string fileName = Encoding.ASCII.GetString(clientData, 4, fileNameLen);
bWrite = new BinaryWriter(File.Open(receivedPath + "/" + fileName, FileMode.Append)); ;
bWrite.Write(clientData, 4 + fileNameLen, receivedBytesLen - 4 - fileNameLen);
bWrite.Close();
clientSock.Close();