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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:30:51+00:00 2026-06-01T02:30:51+00:00

Server works fine, but the problem is the client doesn’t receive anything. server.php <?php

  • 0

Server works fine, but the problem is the client doesn’t receive anything.

server.php

<?php    
 $buf_size = 1024;
 $socket = stream_socket_server("udp://127.0.0.1:3127", $errno, $errstr, STREAM_SERVER_BIND);
 do {
   $str = stream_socket_recvfrom($socket, $buf_size, 0, $peer); 
   $str = "abc";
   stream_socket_sendto($socket, $str, strlen($str), 0, $peer);    
 } while (true);
?>

client.php

<?php
 $fp = stream_socket_client("udp://127.0.0.1:3127", $errno, $errstr);
 if (!$fp) {
    echo "$errno - $errstr<br />\n";
 } else {      
    fwrite($fp, "1 2 3");    
    echo fread($fp, 15);
    fclose($fp);
 }
?>
  • 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-06-01T02:30:53+00:00Added an answer on June 1, 2026 at 2:30 am

    Your syntax for stream_socket_sendto ( resource $socket , string $data [, int $flags = 0 [, string $address ]] ) is wrong, just replace:

    stream_socket_sendto($socket, $str, strlen($str), 0, $peer);

    with:

    stream_socket_sendto($socket, $str, 0, $peer);

    then your example works.

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

Sidebar

Related Questions

My Apache server works fine without -DSSL, but does not start with SSL. This
The listFiles() method of org.apache.commons.net.ftp.FTPClient works fine with Filezilla server on 127.0.0.1 but returns
I'm using System.Nets.Sockets.Socket to play the client side to connect our server. Everything works
okay on our testing server the language works fine whetter your click it twice
I set up subversion on my Windows 2008 server and it works fine locally,
I have a script that works fine on my test server (using IIS6). The
I have a legacy Windows server service and (spawned) application that works fine in
0 I have an ASP.NET 3.0 application that works fine on one server. It
I have an ASP.NET 3.0 application that works fine on one server. It uses
I'm using Server.HtmlEncode on a utf-8 string in asp-classic, which works fine until there

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.