faqts : Computers : Programming : Languages : PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

14 of 21 people (67%) answered Yes
Recently 4 of 10 people (40%) answered Yes

Entry

How to post binary data in write() with PHP socket?

Jan 26th, 2009 21:39
katie shein, healthy man, dman, Jonathan Sharp, chiu jansen, http://www.ttnr.org


I'm not aware of a binary safe function for socket(); But you can use 
the fsockopen() to create a socket....
Here's an example of using fputs() to write binary data (example from 
[email protected] on php.net's comments)
fputs($fp,$binary,strlen($binary));
Also [email protected] posted a comment on specifying the length of 
binary data..
"A note about including length: if you are writing binary data you 
should *always* specify the data's length. The reason is that the 
operating system has a special character to denote end of *strings*, 
but not for binary data. Binary data can be anything, so you can't very 
well reserve an end-of-data character..."
http://php.net/fputs
http://www.healthbyhealth.com
http://www.healthment.com
http://www.mesotheliomadown.com
http://www.mesotheliomaout.com
http://www.pickarticle.com
http://versicherungs101.blogspot.com
http://guiadeseguros.blogspot.com
http://verzekeringengids.blogspot.com
http://osiguranjevodic.blogspot.com
http://seguroguia.blogspot.com
http://ideide-cadouri.blogspot.com
http://gavoride.blogspot.com
http://donsideia.blogspot.com
http://ideeregalo1.blogspot.com
http://partideer.blogspot.com