Jump to content

[SOLVED] Single byte socket send...


omegad

Recommended Posts

I am trying to be able to send data one byte at a time over a TCP socket connection. I want to be able to send hex directly and not use ascii. Right now when I send 0xFF it comes out on the other end as the decimal ascii value not the hex value like it would if i sent a byte in c++. I know the php does not handle bytes but, is there a way to force this?

Link to comment
https://forums.phpfreaks.com/topic/41180-solved-single-byte-socket-send/
Share on other sites

Sorry I guess what i really want to do is send a byte of data from a php socket like I could in C++. The problem is that I need to interface with a binary protocol not an ascii one. What I am trying to do is send data to a networked micro controller which is only 16 bit.

 

Within php the value I send goes through as ascii. In C++ if I have a byte variable and I set it to 0x15 when it gets to the client it comes out as 0x15. In php, however if I set a variable to 0x15 and send it to the client it comes out as ascii 15 a.k.a 0x31 0x35 two bytes not one. I could send single chars since each ascii char is a byte, ex A = 0x41, B = 0x42, etc. However this only gives me a range of 0x21 through 0x7E which does not work for what I need. So I was wondering if there were a way to send straight hex not ascii?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.