title: Sending large packets using php using socket_write
body: <p>I am trying to encode an image to base64 encoding and send it to a C++ server I am creating. I am using PHP to do that.</p>
  
  <p>Therefore, the PHP code is the client and the C++ code is the listening server.</p>
  
  <p>The problem occurs on large images; for example 70KB images. It is working properly on small images; such as 5KB.</p>
  
  <p>The error occurring is: Warning: <code>socket_write() [function.socket-write]</code>: unable to write to socket [0]: A message sent on a datagram socket was larger than the internal message buffer or some other network limit, or the buffer used to receive a datagram into was smaller than the datagram itself.</p>
  
  <p>Can this problem be fixed without dividing the image into several small packets?</p>
  
  <p>I only need the sending packet to be 1MB.</p>
  
  <p>This is the code I am using:</p>
  
  <pre><code>$con=file_get_contents("image url");
  $binary_data=base64_encode($con);
  $host = "192.168.35.54";
  $port = 1060;
  $message = $binary_data;
  // No Timeout 
  set_time_limit(0);
  $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP) or die("Could not create socket\n");
  socket_connect($socket, $host, $port) or die("Could not connect to server\n");
  socket_write($socket, $message, strlen($message)) or die("Could not send data to server\n");
  </code></pre>