SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard Sillysoft's Avatar
    Join Date
    May 2002
    Location
    United States :)
    Posts
    1,691
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Wink PHP And Networking

    Was wondering after reading a article on how to listen to a port and accept information via tcp/ip through telnet, can you go the other way? From your server connect to another server via telnet and pass specified "commands" to grab information from that telnet session and then either save the information in a text file or put it into a database?

    Can someone point me to the right direction? Or is it just plainly a better knowledge of networking is needed?

    Silly

  2. #2
    SitePoint Wizard Mincer's Avatar
    Join Date
    Mar 2001
    Location
    London | UK
    Posts
    1,140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm sure it's possible to do this using php's socket functionality.

    Not sure about how you control a telnet session, but if you can find a reference, I'm sure you can fathom it out.

    Here's a starting point in the manual.

    http://www.php.net/manual/en/function.fsockopen.php

    Matt.

  3. #3
    SitePoint Wizard gold trophysilver trophy
    Join Date
    Nov 2000
    Location
    Switzerland
    Posts
    2,479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP is capable of acting as both a client and a server. Using fsockopen() PHP can become a client and fetch data from a remote "port". Once you open a port, you then need to understand the protocol you're using. Common uses for this are talking to SMTP (email) and HTTP (web) servers. For the PHP web services book I had to do a write up to HTTP which is still available in the sample chapter: http://www.wrox.com/books/sample-cha...1861008074.pdf

    There's also the [ur=http://www.php.net/manual/en/ref.sockets.php]socket functions[/url] which allow you to act as a server (or have more control when building clients. Believe it or not, there's a web server written in PHP: http://nanoweb.si.kz/?p=root

  4. #4
    SitePoint Enthusiast BDKR's Avatar
    Join Date
    Sep 2002
    Location
    Clearwater, Florida
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by HarryF
    PHP is capable of acting as both a client and a server. Using fsockopen() PHP can become a client and fetch data from a remote "port". Once you open a port, you then need to understand the protocol you're using. Common uses for this are talking to SMTP (email) and HTTP (web) servers. For the PHP web services book I had to do a write up to HTTP which is still available in the sample chapter: http://www.wrox.com/books/sample-cha...1861008074.pdf

    There's also the [ur=http://www.php.net/manual/en/ref.sockets.php]socket functions[/url] which allow you to act as a server (or have more control when building clients. Believe it or not, there's a web server written in PHP: http://nanoweb.si.kz/?p=root
    Two others that you may check are PHPServ by Daniel Lorch and PatServer from Pat tools. Both free of course. I'm presently using PatServer as a foundation for controlling the status of databases in a cluster.

    You may also want to check out some sockets tutorials on the net. There are a couple that, although language nuetral in concept, provide examples in C. That shouldn't be too much of a leap for you though.

    Cheers,
    BDKR
    If you're not on the gas, you're off the gas!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •