Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-18-2002, 06:16 PM   PM User | #1
avelonx
New Coder

 
Join Date: Jun 2002
Location: United States
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
avelonx is an unknown quantity at this point
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?
avelonx is offline   Reply With Quote
Old 07-19-2002, 07:42 PM   PM User | #2
Socraties
New Coder

 
Join Date: Jun 2002
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
Socraties is an unknown quantity at this point
$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.
Socraties is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:52 AM.


Advertisement
Log in to turn off these ads.