Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 970177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:45:51+00:00 2026-05-16T02:45:51+00:00

i am developing application which send and receive data between two computers but there

  • 0

i am developing application which send and receive data between two computers but there is problem which i am facing when i send data the file size would be 4.56 kb but when i receive data on other side the file size reduce to 1.42 kb and data write in file also in complete my receiving byte size is 1024 * 5000.i am using c#.i am using TCP

here is my code

i am first sending data to tell other computer what file i want to receive

 private void GetLoginFile()
    {
        Socket clientSock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
        try
        {
            char[] delimiter = splitter.ToCharArray();
            byte[] fileName = Encoding.UTF8.GetBytes(myIP + "_GetLoginFile"); //file name
            byte[] fileData;
            fileData = Encoding.UTF8.GetBytes("null");
            //byte[] fileData = reads.ReadToEnd().to; //file
            byte[] fileNameLen = BitConverter.GetBytes(fileName.Length); //lenght of file name
            clientData = new byte[4 + fileName.Length + fileData.Length];

            fileNameLen.CopyTo(clientData, 0);
            fileName.CopyTo(clientData, 4);
            fileData.CopyTo(clientData, 4 + fileName.Length);
            System.Net.IPAddress ipAdd = System.Net.IPAddress.Parse(serverIP);

            IPEndPoint ipEnd = new IPEndPoint(ipAdd, 9050);
            clientSock.Connect(ipEnd); //target machine's ip address and the port number
            clientSock.Send(clientData);

            byte[] clientData1 = new byte[1024 * 5000];
            string receivedPath = mypath + "XML\\";

            int receivedBytesLen = clientSock.Receive(clientData1);

            int fileNameLen1 = BitConverter.ToInt32(clientData1, 0);

            string fileName1 = Encoding.ASCII.GetString(clientData1, 4, fileNameLen1);
            //string file = Encoding.UTF8.GetString();

            BinaryWriter bWrite = new BinaryWriter(File.Open(receivedPath + fileName1, FileMode.Append));
            bWrite.Write(clientData1, 4 + fileNameLen1, receivedBytesLen - 4 - fileNameLen1);
            //clientSock.Shutdown(SocketShutdown.Send);

            bWrite.Close();
            clientSock.Close();
        }
        catch (Exception ex)
        {
            clientSock.Close();
            MessageBox.Show(ex.Message);
        }
    }

can anyone help me out to solve this problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T02:45:52+00:00Added an answer on May 16, 2026 at 2:45 am

    Well, you haven’t given any code… but I suspect it’s your receiving code which is wrong.

    You should be looping round, reading until a Read call on the stream returns 0. Don’t assume you’ll get all the data in one call.

    EDIT: Yup, look at your receiving code:

    int receivedBytesLen = clientSock.Receive(clientData1);
    

    What makes you think you’ve received all the data you need in that one call? You need to loop round, receiving until either the other end closes the connection, or you’ve read all the data you need.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 497k
  • Answers 497k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Calling the delegate Method does not retain the object. So… May 16, 2026 at 12:00 pm
  • Editorial Team
    Editorial Team added an answer This should clear things up: WCF RIA Services: Returning a… May 16, 2026 at 12:00 pm
  • Editorial Team
    Editorial Team added an answer My take //p[preceding-sibling::h4[1] and not(preceding-sibling::h4[position() > 1])] finds all p… May 16, 2026 at 12:00 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I am going to develop real time application which will receive stock market data
I'm developing an application which requires two interfaces - one for mobile phones browsers
I am developing an application which uses Bluetooth to connect to a device and
i am developing an application in which i will be sending a string to
I am developing application in flex 3 which interacts with the Google feeds to
Issue:- I am developing a application which needs a new acceleration datum every 5
I am in the process of developing an application which uses a legacy USB
I am developing a Math application which can be extended by writing python scripts.
I am developing an iPhone application which will install few third party applications in
I am developing a web application that calls web services developed by a third

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.