SunQuest
           PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old September 18th, 2002, 02:44 PM
bmhm bmhm is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 51 bmhm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Open Socket

I have the following function that is supposed to connect to a socket and then return a pipe (|) delimitated string.

The problem is that it is returning nothing, nada, zero, zilch.

I have put the function below. This is my first time using the socket. Thanks for you help.

php Code:
Original - php Code
  1.  
  2. <?php
  3.  
  4. function authorize($host, $usepath, $postdata = "")
  5. {
  6.     # open socket to filehandle
  7.     $fp = pfsockopen($host, 443, &$errno, &$errstr, 120);
  8.     //pfsockopen(string hostname, int port, int errno, string errstr, int timeout)
  9.     # user-agent name
  10.     $ua = "yourUserAgent/1.0";
  11.     if( !$fp )
  12.     {
  13.         print "$errstr ($errno)<br>n";
  14.     }
  15.     else
  16.     {
  17.         fputs($fp, "POST $usepath HTTP/1.0n" , 1);
  18.         fputs($fp, "User-Agent: ".$ua."n" , 1);
  19.         fputs($fp, "Accept: */*n" , 1);
  20.         fputs($fp, "Accept: image/gifn" , 1);
  21.         fputs($fp, "Accept: image/x-xbitmapn" , 1);
  22.         fputs($fp, "Accept: image/jpegn" , 1);
  23.        
  24.         $strlength = strlen($postdata);
  25.     //  print $strlength;
  26.        
  27.         fputs($fp, "Content-type: application/x-www-form-urlencodedn" , 1);
  28.         fputs($fp, "Content-length: ".$strlength."nn" , 1);
  29.         fputs($fp, $postdata."n" , 1);
  30.         fputs($fp, "n" , 1);
  31.        
  32.         $output = "";
  33.    
  34.         while(!feof( $fp ))
  35.         {
  36.             $output .= fgets($fp, 1024);
  37.         }
  38.        
  39.         fclose($fp);
  40.     }
  41.     return $output;
  42. }
  43. ?>

Reply With Quote
  #2  
Old September 18th, 2002, 03:14 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: Open Socket

Have you tried manually opening a connection to that host and port and sending the data and seeing what response you get?

Reply With Quote
  #3  
Old September 18th, 2002, 04:17 PM
bmhm bmhm is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 51 bmhm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Open Socket

Actually I have not thought about that. How does one go about opening it up manually?

Reply With Quote
  #4  
Old September 18th, 2002, 04:23 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: Open Socket

use any telnet program to connect to that host and port....

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > Open Socket


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway