login about faq

The company I work for developing a chat application that uses something like funXmpp and my job as an Automate QA TL is to test it. I am trying to simulate multiply concurrent users by passing message through CkSocket. when i send regular string the chilkat works fine but when i am sending funxmpp message the chilkat fails. for example if I send "hello" the message is sent fine but if I send "Hix01x05Bye" the string I receive is only "hi". Please suggest my what to do.

asked Oct 26 '15 at 14:27

Shashi's gravatar image


Thanks. The application should pass a CkByteData object in the 1st argument to SendBytes. I noticed the Chilkat online reference documentation had an error (due to the refdoc generation software) and this is now fixed.

Your code should look something like this:


require_once ('chilkat_9_5_0.php'); $socket = new CkSocket(); $success = $socket->UnlockComponent('Anything for 30-day trial'); if ($success != true) { print $socket->lastErrorText() . "n"; exit; }

$ssl = false; $maxWaitMillisec = 20000;

$hostname = 'xyz.something.com'; $success = $socket->Connect($hostname,443,$ssl,$maxWaitMillisec); if ($success != true) { print $socket->lastErrorText() . "n"; exit; }

$socket->put_MaxReadIdleMs(10000); $socket->put_MaxSendIdleMs(10000);

$byte=array('AA','0xFF','0x55','0xAA','0'); $byteData = new CkByteData(); $byteData->append2($byte,5);

$success = $socket->SendBytes($byteData); if (success != true) { print $this->socket->lastErrorText(); //exit; }




answered Nov 10 '15 at 09:57

chilkat's gravatar image

chilkat ♦♦

edited Nov 10 '15 at 09:58

It sounds like you're trying to send non-character bytes (0x01 and 0x05) in a call to SendString? SendString should only be used to send characters (i.e. text where each character corresponds to some glyph or something like a CR, LF, TAB, etc.) Bytes that do not represent characters should not be sent as if they were characters.

Notice that there is a StringCharset property. This controls the byte representation of each character in the string to be sent. For example: utf-8, iso-8859-1, utf-16, etc. Some programming languages, such as C#, VB, etc. have string data types where the programmer is not dealing with the raw byte representation of the charadcters in the string. It is for this reason that methods such as SendString, which are to send a string, need to also know charset -- i.e. HOW each character is to be represented in bytes. How do you represent 0x01 in utf-8? How do you represent the bytes of a JPG image in utf-8? It makes no sense. Therefore, for non-text (i.e. binary bytes) you want to instead use a method that sends bytes -- such as SendBytes.

Another alternative is to send the message in multiple calls. The TCP connection is a stream. There is no delimiting based on what data is sent in which call. You can send what you want in the following sequence of calls:



answered Oct 28 '15 at 14:38

chilkat's gravatar image

chilkat ♦♦

Hi, Thank you for your answer. So I am trying to send the data as bytes like that: $success = $this->socket->SendBytes($data);

And I get the following error: PHP Fatal error: Type error in argument 2 of CkSocket_SendBytes. Expected SWIGTYPE_p_CkByteData in chilkat_9_5_0.php on line 24902

I found nothing about it on the net. Any idea what is wrong?


answered Nov 08 '15 at 11:15

Shashi's gravatar image


The problem of dealing with bytes can be avoided by calling SendBytesENC instead. You can pass the bytes to be sent in the form of an encoded string, using any of the following encodings: "Base64", "modBase64", "Base32", "Base58", "UU", "QP" (for quoted-printable), "URL" (for url-encoding), "Hex", "Q", "B", "url_oauth", "url_rfc1738", "url_rfc2396", and "url_rfc3986".

For example: $success = $socket->SendBytesENC("AAFF55AA00","hex"); This would send the 5 bytes: 0xAA 0xFF 0x55 0xAA and 0x00


answered Nov 10 '15 at 14:35

chilkat's gravatar image

chilkat ♦♦

The code you provided for sending bytearray using chilkat produce PHP Notice: Array to string conversion in chilkat_9_5_0.php on line 1211 what happens is that the object is not passing and the word 'Array' does instead.


answered Nov 11 '15 at 04:56

Shashi's gravatar image


Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Oct 26 '15 at 14:27

Seen: 3,677 times

Last updated: Nov 11 '15 at 04:56

powered by OSQA