Current location: Hot Scripts Forums » Programming Languages » PHP » PHP socket_write combining?


PHP socket_write combining?

Reply
  #1 (permalink)  
Old 08-09-07, 07:21 AM
ealmiladi ealmiladi is offline
Newbie Coder
 
Join Date: Aug 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
PHP socket_write combining?

Okay, I honestly have been sitting up for years trying to figure out this problem.

Basically, I have a Flash AP and I'm sending packets to that ap, but for some odd reason, my packets are combining and not sending when I want to send them.

When a user X's out of the ap in Flash, my PHP socket server picks it up and sends a message to all the other clients that have the Flash ap that this person Xed out, but it's not sending the message until an update from the Flash ap is sent to the server and when that happens, the packets get combined and nothing works.

$buf="SEND_REMOVE|$read_sockets[$index]";
socket_write($client2, $buf, strlen ($buf)) or die("Could not write output\n");

now that's supposed to send the packet right there and then.. but it doesn't

it will EVENTUALLY send the packet, but not until the location to where it's sending sends a packet to the server and then the server responds by sending 2 packets combined into 1.. it may sound confusing, but it's really messed up

please let me know if anyone can help
__________________
Eamon
Go-Veron.com

Last edited by ealmiladi; 08-09-07 at 07:25 AM.
Reply With Quote
  #2 (permalink)  
Old 08-09-07, 02:57 PM
infinitylimit's Avatar
infinitylimit infinitylimit is offline
Code Guru
 
Join Date: Jun 2004
Location: Oregon
Posts: 758
Thanks: 0
Thanked 0 Times in 0 Posts
Your going to have to show full page code for people to be able to understand what is going on. The code you showed and your prose didn't lead me to any conclusions only guesses.
__________________
Hawk Enterprises -- Home to PHP games, open-source code, tutorials and free downloads
Reply With Quote
  #3 (permalink)  
Old 08-09-07, 05:46 PM
ealmiladi ealmiladi is offline
Newbie Coder
 
Join Date: Aug 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
__________________
Eamon
Go-Veron.com
Reply With Quote
  #4 (permalink)  
Old 08-13-07, 01:47 PM
fyrestrtr fyrestrtr is offline
Wannabe Coder
 
Join Date: Nov 2003
Posts: 191
Thanks: 0
Thanked 0 Times in 0 Posts
What kind of socket are you opening? Sounds like your socket drops unless the client initiates a connection.
__________________
Find me at WHT
Reply With Quote
  #5 (permalink)  
Old 08-14-07, 12:58 PM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
a TCP/IP, as you can see in the socket_create function:
PHP Code:

socket_create AF_INETSOCK_STREAMSOL_TCP ); 

__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Reply With Quote
  #6 (permalink)  
Old 08-15-07, 12:05 PM
fyrestrtr fyrestrtr is offline
Wannabe Coder
 
Join Date: Nov 2003
Posts: 191
Thanks: 0
Thanked 0 Times in 0 Posts
I can offer some hints; but without any proper debug of the network traffic, it is difficult to know for certain what is the issue.

TCP is connection initiated and has a wait period; and generally is only used when acknowledge of receipt is necessary. The long and the short of it is, TCP needs to wait for a connection to be established between the client and server, before it can start sending packets. I suspect that this is the problem with your application; could be a lot of other things; but this is the first thing I would look it. You really need to analyze some packets to figure out where exactly the problem is (I'm assuming it is not that you have tripped over some obscure bug in PHP and the issue is with TCP).

However; you really should be using UDP and not TCP in this situation as you need immediate send; but not necessarily acknowledgment of receipt. Try switching to UDP and see if that changes the situation.
__________________
Find me at WHT
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Combining Two Scripts PHP infini PHP 3 08-11-05 03:50 AM
PHP Downside--Solutions? Amulet PHP 10 07-15-05 08:26 AM
PHP multi-dimensional array sorting issue aqw PHP 2 06-24-05 11:09 PM
PHP / Graphic Developers someotherguy582 Job Offers & Assistance 1 06-05-05 07:40 PM


All times are GMT -5. The time now is 06:08 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.