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
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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.