Results 1 to 4 of 4

Thread: PHP fsockopen Functions

  1. #1
    Join Date
    Oct 2008
    Posts
    20

    PHP fsockopen Functions

    fsockopen — Open Internet or Unix domain socket connection

    resource fsockopen ( string $hostname [, int $port= -1 [, int &$errno [, string &$errstr [, float $timeout= ini_get("default_socket_timeout") ]]]] )
    PHP supports targets in the Internet and Unix domains as described in List of Supported Socket Transports. A list of supported transports can also be retrieved using stream_get_transports().

    The socket will by default be opened in blocking mode. You can switch it to non-blocking mode by using stream_set_blocking().

  2. #2
    Join Date
    Dec 2008
    Posts
    65

    Re: PHP fsockopen Functions

    By default php.ini set the user_agent to “PHP” which signifies that it’s the script that try to access the web server. Some web servers will refuse and don’t allow script to access and receive the date from the server.

  3. #3
    Join Date
    Oct 2008
    Posts
    74

    Re: PHP fsockopen Functions

    sockopen() returns a file pointer which may be used together with the other file functions (such as fgets(), fgetss(), fwrite(), fclose(), and feof()). If the call fails, it will return FALSE

    fsockopen() Example

    PHP Code:
    <?php
    $fp 
    fsockopen("www.example.com"80$errno$errstr30);
    if (!
    $fp) {
        echo 
    "$errstr ($errno)<br />\n";
    } else {
        
    $out "GET / HTTP/1.1\r\n";
        
    $out .= "Host: www.example.com\r\n";
        
    $out .= "Connection: Close\r\n\r\n";
        
    fwrite($fp$out);
        while (!
    feof($fp)) {
            echo 
    fgets($fp128);
        }
        
    fclose($fp);
    }
    ?>

  4. #4
    Join Date
    Dec 2008
    Posts
    98

    Re: PHP fsockopen Functions

    fsockopen() Using UDP connection

    PHP Code:
    <?php
    $fp 
    fsockopen("udp://127.0.0.1"13$errno$errstr);
    if (!
    $fp) {
        echo 
    "ERROR: $errno - $errstr<br />\n";
    } else {
        
    fwrite($fp"\n");
        echo 
    fread($fp26);
        
    fclose($fp);
    }
    ?>

Similar Threads

  1. trim functions of VB
    By Ram Bharose in forum Software Development
    Replies: 5
    Last Post: 31-12-2009, 11:51 AM
  2. SQL Scalar Functions
    By Bhardwaj in forum Software Development
    Replies: 5
    Last Post: 15-12-2009, 12:38 PM
  3. How to call a C functions within PHP?
    By Rixwel in forum Software Development
    Replies: 3
    Last Post: 05-09-2009, 09:12 AM
  4. Array Functions in PHP
    By SuperXCM in forum Software Development
    Replies: 2
    Last Post: 26-03-2009, 10:57 AM
  5. Functions in PHP
    By Gyan Guru in forum Guides & Tutorials
    Replies: 3
    Last Post: 13-12-2008, 06:20 PM

Tags for this Thread

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
  •  
Page generated in 1,750,247,255.13459 seconds with 16 queries