Comments (13)
At the moment, I don't have time available to generate PHP bindings myself, but if you want to try doing so, I'd be happy to answer any questions that you get stuck on. I did some quick searching around, and wonder if you've come across this other code that might almost work:
https://github.com/Devristo/phpws/blob/master/phpws/websocket.client.php
(It seems like it may not be updated to the RFC 6455 standard, which is Version 13, but if it implements Version 12, I believe it may be very easy to modify it to support Version 13 and therefore become standard compliant.)
from easywsclient.
Hey.
Sadly the PHP file doesn't work. I am not very compliant with the Websockets protocol yet. Maybe I somehow manage to get PHP bindings. Can you point me to an example c-script so i can test if this project will even compile on Mac OS X?
Regards, Ingwie
Am 26.09.2013 um 22:20 schrieb David Baird [email protected]:
At the moment, I don't have time available to generate PHP bindings myself, but if you want to try doing so, I'd be happy to answer any questions that you get stuck on. I did some quick searching around, and wonder if you've come across this other code that might almost work:
https://github.com/Devristo/phpws/blob/master/phpws/websocket.client.php
(It seems like it may not be updated to the RFC 6455 standard, which is Version 13, but if it implements Version 12, I believe it may be very easy to modify it to support Version 13 and therefore become standard compliant.)—
Reply to this email directly or view it on GitHub.
from easywsclient.
On your OS X, do you have Make and g++? If so, try running make
from inside the easywsclient folder and see if it compiles.
from easywsclient.
It totally build, and the example ran as well. Very good conditions for creating a PHP extension-layer off it :)
Am 26.09.2013 um 22:32 schrieb David Baird [email protected]:
On your OS X, do you have Make and g++? If so, try running make from inside the easywsclient folder and see if it compiles.
—
Reply to this email directly or view it on GitHub.
from easywsclient.
Sounds great. I would love to know how the progress continues.
from easywsclient.
By the way, for what is the -cpp11 binary?
Am 26.09.2013 um 22:45 schrieb David Baird [email protected]:
Sounds great. I would love to know how the progress continues.
—
Reply to this email directly or view it on GitHub.
from easywsclient.
The -cpp11 binary uses features that are only found in newer compilers that support C++11. Since not all compilers support this latest standard, there are two code examples: for C++11 and non-C++11.
from easywsclient.
Hey.
So, I went and did my C lessons, by reading another websockets client called Snacka. It looks good and it would be convertable - BUT it would give me one little big issue. I would have to define a new resource type in PHP and wont be able to use it in a OOP style. But hey, it was good lecture...I now understand how header and header guards work and how I can call a function across source files (i.e. defining square in a.h, declaring it in a.c but calling it from b.c which includes a.h).
Now i am reading over EasyWSClient's hpp file to get an idea on how i'd wrap it up. So far, so good...but, i dont even see a class. I see a namespace, but no class - but a struct. Do structs act like classes in c++? Or where is the client-class?
Regards,
Ingwie
Am 26.09.2013 um 23:11 schrieb David Baird [email protected]:
The -cpp11 binary uses features that are only found in newer compilers that support C++11. Since not all compilers support this latest standard, there are two code examples: for C++11 and non-C++11.
—
Reply to this email directly or view it on GitHub.
from easywsclient.
A struct and class in C++ are exactly the same thing. There is only one subtle difference: in a struct, the members are all public by default; In a class, the members are all private by default and therefore must be declared "public:" to expose anything. I just now updated the code, renaming struct to class, to make it easier to understand for newcomers. (I also did a few other updates as well, to use better coding practices.) Good questions!
from easywsclient.
Thank you!
Eventually, after some lurking, I figured osmething like that first sentence out. So I started to make plans for the port...untill i realized something else. I use an extension called Pthreads that allows my PHP code to multithread. Now, the project states that it is not "thread safe". How would one go ahead and actualy make it thread safe?
My primary use will be to connect to a single websocket (webkit remote protocol). But since my PHP is compiled all threadsafe and such, I wondered if I somehow could make this library threadsafe too. ^^
So far, I get the usage of the functions. Ok, i have a headache, but then again this is purely my first day in which i read over c++ code seriously in order to understand it. :)
Regards~
Am 27.09.2013 um 12:17 schrieb David Baird [email protected]:
A struct and class in C++ are exactly the same thing. There is only one subtle difference: in a struct, the members are all public be default; In a class, the members are all private by default and therefore must be declared "public:" to expose anything. I just now updated the code, renaming struct to class, to make it easier to understand for newcomers. (I also did a few other updates as well, to use better coding practices.) Good questions!
—
Reply to this email directly or view it on GitHub.
from easywsclient.
To safely call easywsclient (and most any other non-thread safe code) from a threaded environment, there are two main options: (1) ensure that exactly one thread ever makes calls into easywsclient or (2) make sure that any thread calling into easywsclient first acquires an exclusive lock (a mutex). This applies to all easywsclient methods (including construction with new and destruction). Locks have some disadvantages - they can lead to deadlocks if used wrong, and they also create bottlenecks that limit the scalability of software. Another disadvantage is that until C++11, there was also no standard lock library for C++ (one could use Boost, Tinythtread++, or a system library like pthread). Because of all of these drawbacks of locks, that is the reason why the code is not thread safe, and users must take care on their own to ensure this safety.
from easywsclient.
Ah! That explains a lot of things. There is just one threat that will be using easywsclient after all. I know that the pthreads extension for PHP has a Mutex option too, i am just not sure how it works yet. x) But maybe I can find a way. Thanks for the explanationt hough, makes many things more understandable. I guess I will first try to get it compiled into PHP and worry about thread safety later on. What I now need to do is following this guide: http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/
That essentialy will help me wrap easywsclient into a PHP class. It doesnt even look very hard. :)
I'll let you know of any process! ^^
Am 27.09.2013 um 12:42 schrieb David Baird [email protected]:
To safely call easywsclient (and most any other non-thread safe code) from a threaded environment, there are two main options: (1) ensure that exactly one thread ever makes calls into easywsclient or (2) make sure that any thread calling into easywsclient first acquires an exclusive lock (a mutex). This applies to all easywsclient methods (including construction with new are destruction). Locks have some disadvantages - they can lead to deadlocks if used wrong, and they also create bottlenecks and limit the scalability of software. Another disadvantage is that until C++11, there was also no standard lock library for C++ (one could use Boost, Tinythtread++, or a system library like pthread). Because of all of these drawbacks of locks, that is the reason why the code is not thread safe, and users must take care on their own to ensure this safety.
—
Reply to this email directly or view it on GitHub.
from easywsclient.
@IngwiePhoenix - closing this issue. Thanks for reporting, and feel free to open any more issues as needed.
from easywsclient.
Related Issues (20)
- getting error when im trying to connect HOT 2
- about vector variable need be clear() and swap()
- not compiled on msys2 HOT 2
- "hostname_connect" funtion code bug
- Memory leak
- from_url() missing close(sockfd)
- Compiling
- connecting to wss through proxy
- How to add parameter at function handle_message
- hello,is there a bug here? HOT 1
- Update npm dependencies to resolve (harmless) security vulnerability in ws
- Check for invalid frame length HOT 1
- VS ERROR LNK2001 Unresolved external symbol easywsclient::WebSocket::from_url HOT 1
- Integrating with OSS-Fuzz HOT 5
- unable to connect: aborted
- Multiple Clients
- >65000 byte send fail
- Half closed connection not handled HOT 1
- Assertion 'ws' failed in ubuntu18.04 HOT 1
- Notifications from the server are not received HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from easywsclient.