SitePoint Sponsor

User Tag List

Results 1 to 9 of 9

Thread: udp & fsockopen

  1. #1
    SitePoint Addict whofarted's Avatar
    Join Date
    Aug 2001
    Location
    lost, If you find me please return me to St.Louis
    Posts
    396
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    udp & fsockopen

    I've been able to get a script to work to get information about a specific Roger Wilco (voice chat program).

    When trying to get this information I got frustrated by the port number. Everywhere I went the post given where for port number 3782. & from here it says
    By default, Roger Wilco communicates with the GameSpy Master Servers on port 27900 (Master Server UDP Heartbeat) and port 28900 (Master Server List Request).
    Now just by a stroke of luck I found a post @ their forum were someone posted something about port 32230. So I tried it & it worked! [img]images/smilies/thumbs_up.gif[/img]

    Now the problem is fsockopen()'s timeout doesn't work (I've seen that posted here & in php.net bug reports). So if the channel is not up at the time someone tries to access my script it will puke all over & kill the whole page. [img]images/smilies/bawling.gif[/img]

    So, my questions are.
    1.) Is there a way around the timeout issue? ( I'm sure there isn't)
    2.) How do people find out what port to connect to? IE: everyone/thing said connect to 3782 but it turned out, to get the info by udp, I needed port 32230.
    3.) How would I find out the ip address that holds the master list for Roger wilco?
    4.) If I find the answer to 3 would the udp port I need actually be 27900/28900 or something different?

    TIA for any help

    back to
    You smell something?

  2. #2
    SitePoint Addict whofarted's Avatar
    Join Date
    Aug 2001
    Location
    lost, If you find me please return me to St.Louis
    Posts
    396
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You smell something?

  3. #3
    SitePoint Addict whofarted's Avatar
    Join Date
    Aug 2001
    Location
    lost, If you find me please return me to St.Louis
    Posts
    396
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You smell something?

  4. #4
    SitePoint Enthusiast Chunks's Avatar
    Join Date
    May 2002
    Location
    Australia
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yo dude...

    good things come to those who wait.....

    Check out this article on DevArticles it might just do the trick, it talks about sockets and ports and that sorta stuff, mentions about fsockopen() problem of not timing out and it gives a solution to that wierd issue.

    http://www.devarticles.com/art/1/484

    Hope this is what ya been lookin for

    Chunks

  5. #5
    SitePoint Addict whofarted's Avatar
    Join Date
    Aug 2001
    Location
    lost, If you find me please return me to St.Louis
    Posts
    396
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    they must not know it but
    PHP Code:
        function control_socket_reset() { 
            if ( 
    $this->contsock ) { 
                    
    // Reset (or set) the timeout on our control socket 
                
    return True
            } else { 
                return 
    False
            } 
        } 
    wont work. If it doesn't get the connection then it "dies" times out on the line
    PHP Code:
     $this->contsock fsockopen($this->hostname$this->portnumb); 
    it never gets past it unless the connection is made.
    You smell something?

  6. #6
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Well, I'm posting from my shiny new install Mozilla Firebird and I have to say I'm impressed

    Have you had a look at the socket and stream functions? They should help a bit.

    Also, maybe this function might be of assistance.

    In regard to finding out the Roger Wilco master list, try download some packet scanning software a scan the packets leaving your computer. Find the ones from RW and find out where they are going.

  7. #7
    SitePoint Addict whofarted's Avatar
    Join Date
    Aug 2001
    Location
    lost, If you find me please return me to St.Louis
    Posts
    396
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the tips, but like I said I think it's a php problem they've yet to address.

    In your link example (yes I looked at all that stuff on php.net btw) lets look at the problem again:
    PHP Code:
    $fp fsockopen("www.example.com"80);
    if(!
    $fp) {
    echo 
    "Unable to open\n";
    } else {
    fputs($fp"GET / HTTP/1.0\n\n" );
    $start time();
    stream_set_timeout($fp2);
    $res fread($fp2000);
    var_dump(stream_get_meta_data($fp));
    fclose($fp);
    print 
    $res;

    creates the same problem because the code never gets past this:
    PHP Code:
    $fp fsockopen("www.example.com"80); 
    or @ least never gets past this
    PHP Code:
    if(!$fp
    it just hangs there if it doesn't get anything.

    Here's an example of my code
    PHP Code:
    $fp fsockopen("udp://" $address$port$errno$errstr2);

    if (!
    $fp)
    {
    $error "ERROR: Unable to connect <br />\n";
    }
    else
    {
    //do this

    the code will NEVER Set the error message because if it's not getting anything back it will just timeout. Note the 2. It's suppose to timeout after 2 seconds if it doesn't connect but it's not working.

    OMG!

    Just typing this I think I found my answer. udp is a connectionless protocal.
    You never make a connection. duh! [img]images/smilies/tongue.gif[/img]

    hmmm, so i wonder what to do if the server isn't up? [img]images/smilies/confused.gif[/img]

    Is there a way to "listen" to a udp broadcast for a specific amount of time then close socket reguardless? Then I could put "any" info gathered into a variable & check to see if it's empty or not.
    You smell something?

  8. #8
    SitePoint Enthusiast M ot U's Avatar
    Join Date
    Jul 2003
    Location
    Earth
    Posts
    54
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Im glad you finally figured it out That never happens with most of my problems
    M ot U == Master of the Universe

    because i am...

  9. #9
    SitePoint Addict whofarted's Avatar
    Join Date
    Aug 2001
    Location
    lost, If you find me please return me to St.Louis
    Posts
    396
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, I figured out why it's not working as expected but still have no solution to the problem.
    You smell something?


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
  •