Mixo123
Mixo123

Reputation: 81

Php-Flash communication over sockets

Good time of the day, dear developers!

I am not any kind of network programming pro, but it happened that I have faced necessity to develop socket-server on php (no way for using Java) for flash multiplayer browser-game (standard features like locations, team battles, etc).


The main problem is that TCP is point-to-point protocol and it completely occupies given port.

Of course it is possible to create some kind of queue, which will manage connections to the socket, but this solution doesn't seems to be the fittest one.

It seems to me that using interval of "fair" ports (from 2000 to 2200, for example) is more fitting solution, because one request may take a lot of time to execute and players won't be happy to wait in queue.

But how can I implement this "port inteval" strategy? The solutions that I see are:

But somehow I don't like any of them, or at least don't know how to implement them in the best possible way.

What is the best existing strategy to handle multiple requests from multiple users per time unit without delays, and how to implement this strategy in php? We have our own Debian-server, so it is possible to use any required php extensions.

Any advice about development, planning and implementation of such kind of systems is highlhy appreciated.

Thank You!


Edit 1: By the way, I've forgotten to mention some extra details.

For example, if we are trying to develop chat application, we need some sort of fixed (I mean persistent) connections for each user. For example, we have 80 users in chat, and then one of them posted a message, which server tries to handle and send to all other connected users, also putting an entry to the history file or something like that.

In this situation polling server for new messages every 10 seconds from each of 80 users is craziness, so the need in persistent connection gets obvious. But I don't know what is the best way to implement something like this, considering that not all requests are handled instanlty.

Upvotes: 2

Views: 811

Answers (2)

Maciek Sawicki
Maciek Sawicki

Reputation: 6835

Best way for multi user communication for Flash is RTMP. Look for FMS or Red5. It's not in php, but I think this is correct way.

Upvotes: 1

Daniel
Daniel

Reputation: 35684

have you looked at http://www.smartfoxserver.com/ or http://www.electro-server.com/ ?

Upvotes: 1

Related Questions