Hello Nathan. Thank you for the suggestion. However, the purpose of this project is of a lower level.
The main purpose is to handle websocket frames at the C level. I am familiar with the library you wrote as I have taken a look at it before. The problem I ran into was when I was trying to send large files using binary websocket frames. Your library handles websocket frame unmasking directly in php which is quite slow. I found that uploading large files took way too long. So, I decided to write my own low level websocket frame handling functions. These functions handle unmasking in low level C and are very fast when compared with handling unmasking of large files. My hope is that developers such as yourself would use these low level functions in their class structures and packages to read and write websocket frames faster than is possible with PHP when trying to handle unmasking of large chunks of data. I used your websocket server to test uploading of a 25M binary file using binary frames. Your websocket server took on average 20 seconds to unmask and process all that data. Then, I modified your code to use the ws_read() function instead. I ran the test again and the same 25M file was fully unmasked, processed, and written to disk in under 2 seconds. Now, when you need to upload say a 1GB file in chunks and display a progress bar to the user, like 15 minutes to unmask all that data using PHP, but takes only a minute or 2 using my low level functions. The reason my functions do not handle multi-threading, etc... is because they are simply low level functions that I believe should be used in classes like yours that handle multiple processes, etc. -- Ray Perea Snap Web Systems Like us on Facebook Follow us on Twitter On Dec 27, 2012, at 10:33 AM, "Nathan Bruer" <[email protected]> wrote: > Might I suggest making this extension into a class structure and make it > multi-threaded to keep blocking issues from happening. > > This project used "on-event" functions on extending classes to deal with the > blocking issues: > https://github.com/nicokaiser/php-websocket > > I wrote this one a while ago that uses multiple threads to deal with > blocking problems: > http://www.phpclasses.org/package/7259-PHP-Handle-Web-socket-accesses-using- > child-processes.html > > > Software Developer > Nathan Bruer > -----Original Message----- > From: Ray Perea [mailto:[email protected]] > Sent: Thursday, December 27, 2012 9:32 AM > To: [email protected] > Subject: [PECL-DEV] I want to publish my extension (php websockets) > > Hello. My name is Ray Perea of Snap Web Systems. (http://www.snapws.com) I > am writing this list because I would like to publish my PHP extension in > PECL > > The extension introduces some functions for reading from and writing to > websockets (RFC6455) > > These functions are: > ws_send() - Send data to a websocket connection > ws_read() - Read data from a websocket connection (Can read binary frames > and files) > ws_close() - Sends a close frame to the websocket client > > I have published the source code at sourceforge: > https://sourceforge.net/p/phpwebsockets > > Please have a look and see if you would like me to publish my extension in > PECL. > Thanks in advance for your consideration. > > -- > Ray Perea > Snap Web Systems Like us on Facebook Follow us on Twitter > > > > >
