You are here: Re: Socket Functions in PHP « PHP Programming Language « IT news, forums, messages
Re: Socket Functions in PHP

Posted by Colin McKinnon on 11/19/90 11:47

O.J. Tibi wrote:

<snip>
> $resource = socket_create( AF_INET, SOCK_STREAM, SOL_TCP );
> $logman->append("Connecting to OLS Server...");
> $socket_conn = socket_connect( $resource, $serverIP, $serverPort );
> if( $socket_conn ) {
> $logman->append("Connected to {$serverIP}:{$serverPort}.
> Sending XML request...");
> socket_write( $resource, $strRequest );
> $logman->append("XML request sent. Waiting for XML
> response...");
> $document = "";
> $data = socket_read( $resource, 1024 );
<snip>
> | 40 | 2006-05-03 15:39:28 | XML request sent. Waiting for XML
> response... |
> | 41 | 2006-05-03 15:40:34 | XML response received.
> |
> | 42 | 2006-05-03 15:40:34 | Buffering complete. Redirecting to
> thanks.php?actiontype=2 |
>
+-------+---------------------+------------------------------------------------------------+


I suggest you point your script at an instance of netcat or similar and see
what's happening. I've not used the socket_ functions but perhaps its not
automatically flushing the buffer? I've not used the socket_ fns but didn't
have this problem using fsockopen().

Also, RTFM - "Note: socket_write() does not necessarily write all bytes
from the given buffer. It's valid that, depending on the network buffers
etc., only a certain amount of data, even one byte, is written though your
buffer is greater. You have to watch out so you don't unintentionally
forget to transmit the rest of your data."

It's generally bad practice not to check the return values of functions.


C.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация