How to connect to REST server with fsockopen

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • scoob19
    New Member
    • May 2010
    • 2

    How to connect to REST server with fsockopen

    I have been trying unsuccessfully to connect to a REST server to get MLS data, pretty much all php scripts/classes use fsockopen to connect and I realized for some reason I can't even get the simple fsockopen function to connect.

    Code:
    $url = "rets17lax.raprets.com";  
    $port=6103; 
    
    $fp = fsockopen($url,$port,$errno,$errstr,30);
    if (!$fp) {
          echo "$errstr ($errno)<br />n";
    } else {   
    
            echo ' 
                Socket connection created to <strong>' . $url . '</strong> on port <strong>' . $port . '</strong> 
            '; 
    
    }
    Ive been told that the rest server is valid, is there something im doing wrong with the fsockopen function? I just cant seem to get it to connect. This is the error:
    Warning: fsockopen() [function.fsocko pen]: unable to connect to rets17lax.rapre ts.com:6103 (Connection refused)

    Thanks!
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    Check your firewall, I'm able to connect.

    You must be having a network issue.

    What do you get when you type in "telnet rets17lax.rapre ts.com 6103" on a command prompt on that PC?



    Dan

    Comment

    • scoob19
      New Member
      • May 2010
      • 2

      #3
      Thanks for the reply Dan. If it's a network issue, would the fsockopen script i copied and pasted still have problems if i upload it to the server? Here is where i uploaded those few lines of code to connect to the RETS server with fsockopen:




      I'm running Vista btw, and to answer your question when i type that into the command prompt on my PC, here is what i get:

      Code:
      HTTP/1.0 400 Bad request
      Content-Type: text/html
      
      <h2>Client sent a bad request.</h2>
      
      Connection to host lost.
      Thanks

      Comment

      • dlite922
        Recognized Expert Top Contributor
        • Dec 2007
        • 1586

        #4
        I was able to run your code as is.

        Code:
        C:\_www\test>php -q -f test.php
        
                    Socket connection created to rets17lax.raprets.com on port 6103
        C:\_www\test>
        Looks like it runs on your server too at the URL you provided.

        I only have the default PHP/MySQL package installed.


        Dan

        Comment

        Working...