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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:37:52+00:00 2026-05-30T18:37:52+00:00

I need a little help with an IRC bot I’m creating (very simple). <?php

  • 0

I need a little help with an IRC bot I’m creating (very simple).

<?php

$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
$yonk = socket_connect($sock, "127.0.0.1", 6667);

$wut = socket_read($sock, 1024);
socket_write($sock, "NICK FikesPHPThingy\r\n");
socket_write($sock, "USER fikeh fikeh fikeh :Fike's PHP thang.\r\n");
socket_write($sock, "JOIN #LightSpike\r\n");

echo $wut;

while (True) {

}
?>

It connects and reads

:de.blank.net NOTICE Auth :*** Looking up your hostname...
:de.blank.net NOTICE 00AAAAAZ4 :*** Skipping host resolution (disabled by server administrator)

But it doesn’t do anything after that. I’m creating this without any tutorials, just by myself. But I can’t seem to get it working. Any ideas?

PS: Sorry for the odd variable names.

  • 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-30T18:37:53+00:00Added an answer on May 30, 2026 at 6:37 pm

    You’ll have to put the (blocking) read inside your infinite loop, like this:

    while (True) {
    $wut = socket_read($sock, 1024, PHP_NORMAL_READ); // $wut will now be a single line sent by the server
    echo $wut; // Do anything with the line
    }
    

    This way your client will continue waiting for and handling response messages until the socket loses connection or you manually break the loop. I’ve added the PHP_NORMAL_READ parameter so the client will read only a single line at a time, this is probably way more practical for processing.

    On a related note, you shouldn’t join a channel right away but rather wait for the 001 response code. This ensures the server has accepted your identification and is ready to receive commands. The way you’re doing it now, the JOIN might (and probably will) be rejected by the server.

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

Sidebar

Related Questions

I need a little help creating a catch-all error handling page in my ICEfaces
I need little help on following requirement, as I know very little about C
I need a little help about a PHP FB app. Matter is that I
I need a little help with php. I'm trying to include different menus for
I need a little help with the fsockopen function. I have this PHP code:
I need a little help with php_auth I have used HTTP authentication with Php
I need a little help with (probably) something really simple. I want to use
Need a little help with a SQL / ActiveRecord query. Let's say I have
I need a little help on this subject. I have a Web application written
I need a little help getting a tar file to download from a website.

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.