Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: Http sockets

  1. #1
    New Coder
    Join Date
    Jun 2002
    Location
    United States
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Http sockets

    I want to open an http socket in php , search the web document for the 2ND "<font color="#FFFFFF" size="+2"><span style="font-size:24"><br>" and the 2ND "</span></font></b></td>"

    1. a <br> 2. b <br> 3. C is between them




    i want it to remove all the "<br>" inbetween and somehow put it in a variable like this
    ------------
    1.A
    2.B
    3.C
    ------------


    so if i were to echo the variable it would return

    1.a
    2.b
    3.c


    COuld someone please show me hwo to do so?

  • #2
    New Coder
    Join Date
    Jun 2002
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts
    $remote = "your.server.address.ordomain";
    $proto = 8003;
    //echo "Remote Host is: $remote<p>";
    $service_port = getprotobyname('tcp');
    $address = gethostbyname($remote);

    $socket = socket(AF_INET, SOCK_STREAM, $service_port);
    if($socket){
    echo "socket has connected<p>";
    }
    $try = connect($socket,$address, $proto);
    $Command = "What you want sent through the socket here\r\n";
    $result = '';
    //Read and Write thorugh socket.
    write($socket, $Command, strlen($Command));
    read($socket,$result,256);
    close($socket);



    Ok how this works is it opens up a connection based on port, which i have set at 8003 but can be any (should be 80 or 443 in your case). The rest of the stuff is pretty standard socket connection stuff. The $Command would be a string array comma deliminated or any other type of format to be sent through the socket. The write command then writes the value of $Command through the socket. The read command reads what is sent back through the socket and stuff it into the $result variable.

    In the result variable is where you would be able to strip out values that you don't want and display the data how you want it to be displayed. I hope this helps ya get started anyways.


  •  

    Posting Permissions

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