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

  • SEARCH
  • Home
  • 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 6182911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:16:42+00:00 2026-05-24T01:16:42+00:00

I have a socket client that would read data from the server. However, it

  • 0

I have a socket client that would read data from the server.

However, it does not leave the do..while loop as soon as there are no more data left to read? why is that so? Thanks

while (true)
{
    $data_old=$data;
    $data = file_get_contents("userInput.txt");

        if($data_old != $data)
        {
            socket_write($socket, $data, strlen($data));
            do
            {
                $line =@socket_read($socket,2048);
                echo $line. "\n";
            }
            while($line != "");
        }

}
  • 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-24T01:16:42+00:00Added an answer on May 24, 2026 at 1:16 am

    i solved it using another method. By my server sending a (” “) statement to the client after all the data has been sent.

    Client side will then exit that loop upon receiving the statement.

    while (true)
    {
        $data_old=$data;
        $data = file_get_contents("userInput.txt");
    
            if($data_old != $data)
            {
                socket_write($socket, $data, strlen($data));
                do
                {
                    $line =@socket_read($socket,2048);
                    if($line != " ")
                    echo $line. "\n";
                }
                while($line != " ");
            }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a server that sends data via a socket, the data is a
We have a simple project where we read data from a socket and we
Hey gang. I have just written a client and server in C++ using sys/socket.
I have a class that encapsulates tcp socket communications with a server. For each
I have a server that listens for a connection on a socket: public class
I have a Php application using stream_socket_client(), to get data through tcp from a
I want to open a TCP client socket in Python. Do I have to
I have a c# application that runs as a windows service controlling socket connections
I have a worker thread that is listening to a TCP socket for incoming
I'm attempting to write song data to a socket however after approximately 66338 bytes

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.