View Full Version : Http sockets
07-18-2002, 06:16 PM
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
so if i were to echo the variable it would return
COuld someone please show me hwo to do so?
07-19-2002, 07:42 PM
$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);
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));
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.
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.