Click to See Complete Forum and Search --> : sockets and multiple lines


kloon_za
03-05-2007, 07:03 AM
Hey im writing a smal php based irc bot that uses sockets to talk with the irc server. Now my problem is im not getting all my data through to the server if it has multiple lines.


function cmd_send($command)
{
global $con, $time, $CONFIG;
/* Send the command. Think of it as writing to a file. */
fputs($con['socket'], $command."\n\r");
/* Display the command locally, for the sole purpose
of checking output. (line is not actually not needed) */
print (date("[d/m @ H:i]") ."-> ". $command. "\n\r");

}

if(strtoupper(substr($con['buffer']['text'], 0, 7)) == '!EPINFO'){
$eps = strtoupper(substr($con['buffer']['text'], 8, strlen($con['buffer']['text'])-2));
$info=file_get_contents('http://episodeworld.com/botsearch/'.$eps);
print(rtrim($info));
cmd_send(prep_text("please",strip_tags($info)));
}


I only get the first line through

michael879
03-05-2007, 08:17 PM
not an expert on sockets, but I have used them. Ill try to help you find your problem if the following doesnt work:

I believe its supposed to be '\r\n' not '\n\r'. Also, I think just using '\n' would work. Not sure what happens when you put \r after \n, but it could be your problem.

MrCoder
03-06-2007, 06:21 AM
Try..


$final_command = $command."\r\n";
fputs($con['socket'], $final_command, strlen($final_command));


Hope that helps.