Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 118,860 PHP Programmers for FREE! Ask your question and get quick answers from experts. There are 1,689 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Telnet/PHP

 
Reply to this topicStart new topic

Telnet/PHP, telnet/php...there and back again

woodjom
post 24 Jul, 2008 - 07:37 AM
Post #1


New D.I.C Head

*
Joined: 8 May, 2008
Posts: 43



Thanked 1 times
My Contributions


I currently have been able to connect to the telnet client but am wondering how i can take that connection and data not interface information back and forth?
User is offlineProfile CardPM

Go to the top of the page


Moonbat
post 24 Jul, 2008 - 09:05 AM
Post #2


D.I.C Head

Group Icon
Joined: 30 Jun, 2008
Posts: 248



Thanked 14 times

Dream Kudos: 575
My Contributions


QUOTE(woodjom @ 24 Jul, 2008 - 07:37 AM) *

I currently have been able to connect to the telnet client but am wondering how i can take that connection and data not interface information back and forth?

Are you trying to connect to Telnet with PHP? You would just use the fsockopen() function and connect on port 23.
User is offlineProfile CardPM

Go to the top of the page

woodjom
post 24 Jul, 2008 - 10:38 AM
Post #3


New D.I.C Head

*
Joined: 8 May, 2008
Posts: 43



Thanked 1 times
My Contributions


here is the code i have...

php

$engine = 'telnet.add.com';
$port = '3030';

$connection = fsockopen($engine, $port);

if(!$connection){
echo "Connection Failed";
}else{
echo $connection;
echo '<br/>';
echo "Connection Succesful";
}


i can get the successful verification of the connection being a success...just need know how to send data to and receive response data from the engine i have located at the location.

if i could get a function set to use....couldnt see any from the php forum that would interact over the telnet socket.
User is offlineProfile CardPM

Go to the top of the page

ellisgl
post 24 Jul, 2008 - 11:40 AM
Post #4


D.I.C Head

**
Joined: 10 Nov, 2007
Posts: 56



Thanked 1 times
My Contributions


Use the read and write functions - fread, fgets, fwrite, fputs. I'll post some sample code.
User is offlineProfile CardPM

Go to the top of the page

ellisgl
post 24 Jul, 2008 - 11:53 AM
Post #5


D.I.C Head

**
Joined: 10 Nov, 2007
Posts: 56



Thanked 1 times
My Contributions


CODE

<?php
$host   = 'telnet.add.com';
$port   = '3030';
$user   = 'User';
$pass   = 'Pass';
$socket = fsockopen($host, $port) or die('Could not connect to: '.$host);

// "Endless" loop
while(1)
{
  while($line = fgets($socket, 1024))
   {
    // Code to deal with the output.
    switch($line)
     {
      case 'user:'
       fputs($socket, $user."\r\n");
      break;

      case 'password:'
       fputs($socket, $pass."\r\n");
      break;
    
     default:
      // More code..
   }
}
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 10/13/08 01:45AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month