I have to built a multilayer game using web-sockets. For this I have a a shared web server with Apache. Browser is not an issue I am building for modern browsers only.
I tried few example PHP and web-socket source code but no luck.
What do I need to do?
And also how to enable the PHP socket_create function? Already enables php_sockets extension in the php.ini and also the php_sockets.dll exists in the extension directory.
When I call socket_create function php says that this function is undefined.
Any kind of help is appreciated.
Thanks
It seems that the command prompt was using a different configuration file for PHP.
Apache (or from the WAMP's interface) uses a php.ini that is located at:
[WAMP_DIRECTORY]\bin\apache\Apache2.2.21\bin\php.ini
If you will open this file, you may notice that the line extension=php_sockets.dll is already commented out.
Unfortunately, the CLI or command line interface is using a different configuration file which is located at:
[WAMP_DIRECTORY]\bin\php\php5.3.8\php.ini
In order to resolve it, you should comment out the line extension=php_sockets.dll and save it. Run the program after to see if the websockets again are already up and working.
If you can guarantee WebSocket support in the browser then use Ratchet. It won't run within Apache, but as a separate process.
There are other options available too - see the realtime web tech guide.
Questions related to WebSocket + PHP have been asked a number of times on SO. I'd recommend doing a search for best solutions and known gotchas when using Apache, PHP + WebSocket. Here's are a couple of good starting question with some additional links in the answers:
Is native PHP support for Web Sockets available?
Efficient reloading data / pushing data from server to client
Related
We are using Laravel Octane (with Swoole) and are struggling to get Xdebug working consistently (PhpStorm and Docker). It seems to work (hits breakpoints) and then stops when we make code changes.
Is this something to do with Swoole? Do we need to be using Yet Another Swoole Debugger?
According to the OpenSwoole documentation, swoole is not compatible with xdebug.
Generally, PHP works in a request/response mode. All of the PHP extensions assume that this is how PHP will run. And that's not how swoole works.
Apart from xdebug, more extensions will not work when you use swoole: phptrace, aop (Aspect Oriented Programming), xhprof, Phalcon, BlackFire, Datadog, Newrelic? (swoole is not on the list of officially supported web servers).
While the situation may improve over time, currently, many "low level" extensions will not be compatible with swoole.
I have to create a little AJAX chat in my web application and I'm dealing with problem of real-time communication between JavaScript client and PHP server.
I want my js client to be able to catch new messages from the server as quick as possible. My first idea was to create AJAX request for example each 5 sec. to see whether there are new messages.
However, I'm not sure what happens if my application use for example 1000 people, it must be huge load to Apache httpd.
I also know about technique called 'long-polling' request, but when I tried that locally on my server, I've completely shooted down my Apache (I've read sth about problems with apache and long-polling). The next way I know about is WebSocket.
However, is it true that I have to be able to open port on webserver to use it? Because on regular web hosting, I thing it's not possible and I cant change any Apache/PHP settings on my hosting.
Do you have any suggestions how to solve it?
If you want to use websockets, you better have full control over your server as you may be facing the need to start and stop the websocket daemon whenever it's needed.
I wouldn't recommend using "regular web hosting" because of its restrictions.
I think that you are looking for "virtual server providers", that provides you full control over the server you manage. You should look at Amazon Web Services. There are many others that you may find.
I'm not sure which technology I should be using, or even what exactly I'm trying to do is called, so I was hoping to just get some guidance on the issue.
We have a client/server architecture, and from the client side you should be able to send a command to the server side either by going from Browser -> Client -> Server, or just directly from Browser -> Server
My question is, what should I be looking in to to help me accomplish this task? I believe if I were to use a Chrome Extension, it would have to use NPAPI to interact locally with my PC, which is less than recommended ;)
The solution only needs to work on Windows, and will not be accessing any of the local users files.
Thanks for your help!
Within Chrome Extensions, you are allowed to access external resources if and only if you explicitly define the permissions (url pattern) in the manifest file.
Depending on the need of your application, you could use RESTful server approach or WebSockets server approach. Once you finish developing your server, your extension can communicate through it using existing web technologies (XmlHTTPRequest, WebSocket).
Assuming your going to use RESTful, what I would do is create a JavaScript service class/library that communicates to your backend (Server) using XHR, and include that in your background page within the extension. Then you can use Extension Message Passing to communicate to your service class.
Think of it as this, the scripts defined in the background context within your extension lives in between your extension and your server, acting like a facade. Search on GitHub/StackOverflow if you need questions regarding how, there are many useful posts/projects.
I am really confused at to how Meteor works.
I know there's a server side where you just install it using the terminal.
But what about the client?
Does the client need to install anything?
For example, clients need to install Adobe Flash to run Flash. Are we talking about the same thing here? Or can the client just access it through a regular page without installing anything.
Thanks for the clarification.
<3 StackOverflow
Meteor is a pure javascript web-application framework.
All you need to run meteor is a JavaScript environment.
Server-side, NodeJS is the gold standard javascript environment.
Client-side, all you need is a browser that supports javascript.
There are no plugins required or other magic at work. It's just javascript.
I am assuming you mean the Meteor Http Server? In this case, you can think of it as being very similar to SignalR or node.js. Basically javascript on the client handles receiving events that come back from the server, so you will generally need to include a script on the client side.
You may want to read the following links for more information.
http://meteorserver.org/browser-techniques/
http://www.hanselman.com/blog/AsynchronousScalableWebApplicationsWithRealtimePersistentLongrunningConnectionsWithSignalR.aspx
I think the question refers to http://meteor.com, and if that is the case the client does not need to install anything.
Meteor is a framework for writing Javascript applications, and as such all modern browsers support it "out of the box". The initial request for a web site will download the HTML, CSS and Javascript and it will run just as any other web application like GMail, etc.
You can check out a series of example applications at http://madewith.meteor.com and you should be able to run them without adding any plugins, etc.
I have inherited a Windows Server and I have to deploy a django app on it.
Have anyone tried to benchmark http servers with django support on this platform?
Which one is fastest?
Use-case of my application would be:
not so much writes to db
heavy usage of admin panel
display tons of results
Have you looked at either wamp or xampp? They both deliver Apache/MySQL/PHP-and-Perl on a Windows platform. But you need more because neither includes Python. See this SO thread for how to proceed from there. Note, you may encounter problems. See this SO thread for an example.
Ps. Personally, I would just get a an account that supports Django (e.g. webfaction.com) and not screw around with this.
I run a Django site on Windows using Apache. I've posted a write up about some of the hurdles that you're going to face.