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 6062647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:04:33+00:00 2026-05-23T09:04:33+00:00

Problem I have PHP client which sends a image file to a C# socket

  • 0

Problem

I have PHP client which sends a image file to a C# socket server. My problem is about 30% of the time the file is partially transferred and stops.

PHP END ->

$file = file_get_contents('a.bmp');
socket_write($socket,$file);

C# END ->

 int l= Socket.Receive(buffer, buffer.Length, SocketFlags.None);
  //create the file using a file stream

How can I always transfer the full file without intermediate states? And why does it happen?

  • 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-23T09:04:34+00:00Added an answer on May 23, 2026 at 9:04 am

    From the documentation for Socket.Receive:

    If you are using a connection-oriented Socket, the Receive method will read as much data as is available, up to the number of bytes specified by the size parameter. If the remote host shuts down the Socket connection with the Shutdown method, and all available data has been received, the Receive method will complete immediately and return zero bytes.

    This means you may get less than the total amount. This is just the way sockets work.

    So if if you get a partial read, you should call Socket.Receive again. You can use the overload of Socket.Receive to continue reading into the same buffer.

    Here is an article that shows how “keep reading” until you get what you want:

    • Socket Send and Receive

    If you don’t know how big the data is, you must keep reading until Socket.Receive returns zero.

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

Sidebar

Related Questions

I have a TCP connection , which client is PHP and server is C#
I have a problem with my path. Say I have a PHP file in
I have problem with session in cakephp.I have one file chat.php that is in
I have a PHP login which sets 2 cookies once someone login. The problem
I have a problem in integrating PHP and JQuery: My main file is MyFile.html
My problem is the following: I have a real simple PHP file called writeSettings2.php
I have a form which sends data with the POST method, about 3000 array
I have a PHP file for my website, index.php, which, as it stands on
I have a php script which sends user a mail if his purchase is
I'm having a strange problem in that I have php inserting text into a

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.