Re: [PHP] Socket Functions in PHP

2006-05-08 Thread Richard Lynch
On Sun, May 7, 2006 11:22 pm, Oliver John V. Tibi wrote:
>   while ($data != "") {
>   $document .= $data;
>   $data = socket_read( $resource, 1024 );

$logman->append("Read " . strlen($data) . " bytes");

>   }

This is going to help you pin-point the timing issue.

Is it taking a full minute to read/buffer that data?

Or does it all get sucked down and then a minute is lost?

Or, is it a minute lost and then all the data rushes through?

>   $logman->append("XML response received.");

> |40 | 2006-05-03 15:39:28 | XML request sent. Waiting for XML
> response...  |
> |41 | 2006-05-03 15:40:34 | XML response received.

> As you can see, there is a lapse of more than one minutes between
> LogId's 40 and 41, which is very slow on a production environment. The
> script above acts as a client to another application server listening
> on
> a remote port, running on Java. What the remote application reports is
> that it receives the connection request, receives the request data,
> and
> transmits the response data at the same second, while my application
> receives the response one minute after the request was sent!

How certain are you of the logging on that Java server?...

I've had a similar situation, though we were fighting over 10 seconds
instead of 60, where the other vendor's timings and ours never did
match up.

I'd like to report that we solved the problem...

But since the solution involved ditching that vendor and choosing
another one, I don't think you want to hear about it... :-v

NOTE:
We are a Un*x shop; They were a Windows shop.
Near as I can tell, that right there was the source of the problem...

PS
We went through a lot of hoops with the first vendor to try and work
things out, including installing their application on a Windows server
in our rack (ugh!), to get network lag time to minimum.

They had Admin login on the Windows box, and we told them to do
whatever it takes to get it fast.

We spent a FORTUNE on that box, and waay too much time trying to
make things work out with them.  Bent over backwards to make it work
before giving up on them.

It was very frustrating, because they kept reporting that their box
was sending things out in X seconds, and we kept seeing 3*X seconds
for how long the data took to arrive. :-(

They kept asking for our source code, and it took them weeks to grasp
that this was all there was to it:
$start = microtime();
$data = file_get_contents($their_url);
$end = microtime();

For some reason, they like it much better when I added a loop such as
you have, even though that only made things worse...

We never did agree on how long it took their box to do things -- I
couldn't even run their test programs locally on that Windows box and
get the same numbers they did...

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Socket Functions in PHP

2006-05-07 Thread Oliver John V. Tibi

Hi all,

I suspect I'm having problems with socket functions within my PHP 
application running on Red Hat 2.4.21-4.EL #1/PHP 4.3.2/Apache 2.0.46.


Below is a sample code listing:



function sendRequest($strRequest) {
$parser = NULL;
$logman = new LogManager();

$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 );

while ($data != "") {
$document .= $data;
$data = socket_read( $resource, 1024 );
}
$logman->append("XML response received.");

$parser = new OlsResponseParser;
// parse the received document using our parser
$parser->parse($document);
}

if ($parser != NULL) {
return $parser->getOlsResponse();
}

return $parser;
}


The following listing is from the logs I have created...


|+---+-++
| LogId | LogDate | LogMessage 
   |

+---+-++
|37 | 2006-05-03 15:39:28 | /new_userpage_process.php initialized. 
Creating buffer...  |
|38 | 2006-05-03 15:39:28 | Connecting to OLS Server... 
|
|39 | 2006-05-03 15:39:28 | Connected to (server):(port). Sending 
XML request... |
|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 |

+---+-++

 

As you can see, there is a lapse of more than one minutes between 
LogId's 40 and 41, which is very slow on a production environment. The 
script above acts as a client to another application server listening on 
a remote port, running on Java. What the remote application reports is 
that it receives the connection request, receives the request data, and 
transmits the response data at the same second, while my application 
receives the response one minute after the request was sent!


Other implementations in the enterprise using different architectures 
and technologies/languages do not experience the same issue as my app does.


Please help. Comments, suggestions and thoughts through the group or 
private mail are deeply appreciated.


Thanks!
--
Oliver John V. Tibi
Software Programmer/Web Application Developer
IAMD Software Solutions
[EMAIL PROTECTED]
"Live free() or die()."

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Socket functions

2005-08-30 Thread Philippe Reynolds

WOW...so much simpler..thank you very much!!

Cheers
Phil

style='FONT-SIZE:11px;FONT-FAMILY:tahoma,sans-serif'>size=1>
From:  Burhan Khalid <[EMAIL PROTECTED]>To:  Philippe 
Reynolds <[EMAIL PROTECTED]>CC:  
php-general@lists.php.netSubject:  Re: [PHP] Socket 
functionsDate:  Tue, 30 Aug 2005 09:49:22 
+0300>Philippe Reynolds 
wrote:>>Greetings,When I do an ifconfig in 
unix, I see the the IP address for the my >>ethernet.  It follows 
something called inet.Would anyone know who to 
manipulate the socket functions to be able >>to extract the inet 
IP address fromt the eth0 section??>>>  
 exec('ifconfig eth0 | grep 
inet',$output);>preg_match("|[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}|",$output[0],$matches);> 
  echo $matches[0];>>?>


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Socket functions

2005-08-29 Thread Burhan Khalid

Philippe Reynolds wrote:

Greetings,

When I do an ifconfig in unix, I see the the IP address for the my 
ethernet.  It follows something called inet.


Would anyone know who to manipulate the socket functions to be able to 
extract the inet IP address fromt the eth0 section??




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Socket functions

2005-08-29 Thread Philippe Reynolds

Greetings,

When I do an ifconfig in unix, I see the the IP address for the my ethernet. 
 It follows something called inet.


Would anyone know who to manipulate the socket functions to be able to 
extract the inet IP address fromt the eth0 section??


Cheers
Phil

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] socket functions and singnals

2002-03-24 Thread Michael Govorun

Socket functions, such as socket_read(), socket_accept() blocking
signal handling in php-processes. Is it bug? Is there any way to use
signals and socket_accept() together?

Please, help!

-- 
Michael Govorun

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Socket functions

2001-12-19 Thread David

 Hi, just wondering if anyone have tried the socket functions in php 
http://www.php.net/manual/en/ref.sockets.php

does it work on win32(apache)? i tried the simple TCP/IP example on that page but it 
does\'nt work for me. I\'m using 4.1.0 and enabled that entension already.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Socket functions

2001-05-10 Thread Peter Sorger

Hello,

I cannot make the Example 1 (Socket example: Simple TCP/IP server) from the
sockets php manual page (http://www.php.net/manual/en/ref.sockets.php) work
:(

It always closes the connection after one line passed throug the server
script :(

I'm running it on 4.0.3pl1 CGI version.

Am I doing something wrong ? Does anybody have a solution for this problem ?

Thank you

[EMAIL PROTECTED]

---
Odchádzajúca správa neobsahuje vírusy.
Skontrolované antivírusovým systémom AVG (http://www.grisoft.cz).
Verzia: 6.0.250 / Vírusová databáza: 123 - dátum vydania: 18. 4. 2001



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Flash XMLSocket object and the PHP socket functions

2001-04-09 Thread Frank Joerdens

I am currently thinking about how to implement a realtime chat using the
XMLSocket functionality in Macromedia Flash 5 using the PHP socket
functions. Here's a quote from the Flash 5 online help:

--- begin quote ---
Using the XMLSocket object

To use the XMLSocket object, the server computer must run a daemon that
understands the protocol used by the XMLSocket object. The protocol is
as follows: 

 XML messages are sent over a full-duplex TCP/IP stream socket
connection. 
 Each XML message is a complete XML document, terminated by
a zero byte. 
 An unlimited number of XML messages can be sent and
received over a single XMLSocket connection. 

The XMLSocket object is useful for client-server applications that
require low latency, such as real-time chat systems. A traditional
HTTP-based chat solution frequently polls the server and downloads new
messages using an HTTP request. In contrast, an XMLSocket chat solution
maintains an open connection to the server, which allows the server to
immediately send incoming messages without a request from the client. 

Setting up a server to communicate with the XMLSocket object can be
challenging. If your application does not require real-time
interactivity, use the loadVariables action, or Flash's HTTP-based XML
server connectivity (XML.load, XML.sendAndLoad, XML.send), instead of
the XMLSocket object. 

To use the methods of the XMLSocket object, you must first use the
constructor, new XMLSocket, to create a new XMLSocket object. 
--- end quote ---

Does anyone have any knowledge of similar projects/attempts to create a
server in PHP that would be able to talk to a client that uses the Flash
5 XMLSocket object, or would anyone care to provide some pointers to
other resources about it? I've never tried to write a server, but this
might solve quite a few problems that I encounter on a day-to-day basis.
Http really sucks when you try to do anything vaguely more complicated
than a mailto form, seeing that it is a stateless protocol . . . and
Flash 5 could fill that gap for the stuff I'd like to do at least.

Regards, Frank

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] socket functions

2001-04-04 Thread Joseph Blythe

Yasuo Ohgaki wrote:

> Did you read the Manual?

The manual is my bible I always read it before I post. Also searched 
google and the list archives.

> socket_set_blocking

As far as I can tell this does not work for the new socket functions, 
the file descriptor does not seem to be compatible? (it returns an 
error) You have to use set_nonblocking() which doesn't seem to work.

> There is note that says it does not work with PHP4/Win32. I may need to check
> BugDB to find out status of this problem.

I am running linux so this should not matter.

Thanks for your reply,

Regards

Joseph





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] socket functions

2001-04-04 Thread Yasuo Ohgaki

Did you read the Manual?

>From PHP Manual
=
socket_set_blocking

Description
int socket_set_blocking (int socket descriptor, int mode)

If mode is false, the given socket descriptor will be switched to non-blocking
mode, and if true, it will be switched to blocking mode. This affects calls like
fgets() that read from the socket. In non-blocking mode an fgets() call will
always return right away while in blocking mode it will wait for data to become
available on the socket.
This function was previously called as set_socket_blocking() but this usage is
deprecated.
=

There is note that says it does not work with PHP4/Win32. I may need to check
BugDB to find out status of this problem.

I compile with --enable-sockets, so I don't know if it available without it.

Regards,
--
Yasuo Ohgaki


"Joseph Blythe" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>
>
> Joseph Blythe wrote:
>
> > hello,
> >
> > does anyone know if set_nonblock() works, what paramaters it takes
> > and  what it returns?
> >
> > there is only one mention of it in the manual under accept_connect,
> > and  I can not seem to  set the socket to non block??
> >
> > also has anybody successfully written a way to time out a read with
> > the  new socket fuctions I can not get this to work eithier.
> >
> > any help would be appreciated,
> >
> > regards,
> >
> > joseph
>
> Well after no response from this list I can assume that this function is
> indeed dead, I had to go back to the generic network functions to get a
> non blocking socket to work and be able to wrap a loop around the socket
> read to time it out after so many seconds. If anyone knows any different
> please let me know.
>
> Regards
>
> Joseph
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] socket functions

2001-04-03 Thread Joseph Blythe



Joseph Blythe wrote:

> hello,
> 
> does anyone know if set_nonblock() works, what paramaters it takes 
> and  what it returns?
> 
> there is only one mention of it in the manual under accept_connect, 
> and  I can not seem to  set the socket to non block??
> 
> also has anybody successfully written a way to time out a read with 
> the  new socket fuctions I can not get this to work eithier.
> 
> any help would be appreciated,
> 
> regards,
> 
> joseph

Well after no response from this list I can assume that this function is 
indeed dead, I had to go back to the generic network functions to get a 
non blocking socket to work and be able to wrap a loop around the socket 
read to time it out after so many seconds. If anyone knows any different 
please let me know.

Regards

Joseph




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] socket functions

2001-04-02 Thread Joseph Blythe

hello,

does anyone know if set_nonblock() works, what paramaters it takes and 
what it returns?

there is only one mention of it in the manual under accept_connect, and 
I can not seem to  set the socket to non block??

also has anybody successfully written a way to time out a read with the 
new socket fuctions I can not get this to work eithier.

any help would be appreciated,

regards,

joseph



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] socket-functions

2001-01-14 Thread Christoph Aigner

hello,

is it possible to use the socket-functions within a windows-environment, or
are they for linux-distributions only ...?


regards christoph


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]