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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:35:46+00:00 2026-05-27T01:35:46+00:00

Im using VCL to broadcast to my localhost, 127.0.0.1 with UDP (legacy) method. To

  • 0

Im using VCL to broadcast to my localhost, 127.0.0.1 with UDP (legacy) method. To catch the traffic, I use this code:

$address = '127.0.0.1';
$port = 1234;
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
socket_bind($sock, $address, $port) or die('Could not bind to address');
$f = fopen ('output', 'w');
fclose ($f);
$sock = stream_socket_server('udp://127.0.0.1:1234', $errno, $errstr, STREAM_SERVER_BIND);
while(1)
{
    $a = stream_socket_recvfrom($sock, 65536);
    $f = fopen('output', 'a');
    fwrite ($f, $a);
    fclose ($f);
    @ob_flush();
}

this logs the packets and saves, I rename it to .MP4 and open – well, the result is a little messy. I can recognize the output, the top screen is visible, the lower part is not good. I tried to capture it with another VCL player, and there were no 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-27T01:35:47+00:00Added an answer on May 27, 2026 at 1:35 am

    Here is your code with a lot of useless stuff removed and a few efficiency improvements. Try it out and see what happens. It may or may not fix the problem, but report back with what happens and we’ll take it from there.

    // Settings
    $address = '127.0.0.1';
    $port = 1234;
    $outfile = "output.mp4";
    
    // Open pointers
    if (!$ofp = fopen($outfile, 'w'))
      exit("Could not open output file for writing");
    if (!$ifp = stream_socket_server("udp://$address:$port", $errno, $errstr, STREAM_SERVER_BIND))
      exit("Could not create listen socket ($errno: $errstr)");
    
    // Loop and fetch data
    // This method of looping is flawed and will cause problems because you are using
    // UDP. The socket will never be "closed", so the loop will never exit. But you
    // were looping infinitely before, so this is no different - we can address this
    // later
    while (!feof($ifp)) {
      if (!strlen($chunk = fread($ifp, 8192))) continue;
      fwrite($ofp, $chunk);
    }
    
    // Close file pointers
    fclose($ofp);
    @fclose($ifp);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In code I have developed some years ago I have been using this a
I am using docking (VCL) in Delphi 7. In my main form, two other
I'm using Delphi7 (non-unicode VCL), I need to store lots of WideStrings inside a
Using LINQ on collections, what is the difference between the following lines of code?
using (var file_stream = File.Create(users.xml)) { var serializer = new XmlSerializer(typeof(PasswordManager)); serializer.Serialize(file_stream, this); file_stream.Close();
Using Flex 3, I would like to take an image snapshot such as this:
I am working in the Borland C++Builder IDE, using VCL controls. I am trying
We have a platform using VCL TFrame as rendering surface for OpenGL. Using FireMonkey,
I am using C++ Builder to create a VCL form application. Right now I
I'm using the Application.MessageBox to show messages on my VCL application, but when the

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.