Jump to content
[MUST READ] Forum Rules ×

Socket Queries in Free Hosting


Recommended Posts

Hello,

I'm currently working on a project that requires querying a specific DNS server. Unfortunately, on Free Hosting, I'm encountering an issue where the DNS query process isn't working as expected. Here's the part o my of code I'm that is sending and recieving the socket data:

$socket = fsockopen("udp://$dnsServer", 53, $errno, $errstr, 5);
if (!$socket) {
return "Socket creation failed: $errstr ($errno)";
}
// Send the DNS query to the specified DNS server
if (!fwrite($socket, $packet, strlen($packet))) {
return "Failed to send data";
}
// Receive the response
$response = fread($socket, 512);
if ($response === false) {
return "Failed to receive data";
}
 
I'm consistently receiving a "Failed to receive data" error, indicating that my script is unable to retrieve the data from the socket. Could there be any limitations or restrictions on Free Hosting that could be causing this issue?
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...