"Phantom character" in Socket (RESOLVED)

Hi everyone:

I have built a tcl script, this script communicate with an ADA program trough a socket, sending binary data, the sender proc is this one:

The code where im sending info is here:

proc p_send_data { DATA } {
  global connection
  puts "Sending trough $connection..."
 
  # This is just the string of bytes im sending
  binary scan $DATA H22 hexa
  puts "IM SENDING THIS ------>  $hexa"

  # Put it trough socket
  puts -nonewline "$connection" $DATA
  flush $connection
  }

It usually works fine, but with some values of DATA, socket, a little demon or something is adding a byte to my string !!

The output of program "IM SENDING THIS -----> 0109450900018813bc0400"

Like you can see this line is printed just before puts data in socket.

The "tcpdump" capture ----------------------------------> 010945090001c28813bc0400

The bytes are the same excepts that c2 insertion.

With strace i can see how system writes in socket this:

write(1, "IM SENDING THIS ------>  010945090001"..., 44IM SENDING THIS ------>  0109450900018813bc0400) = 44
sendto(4, "\1\tE\t\0\1\302\210\23\302\274\4\0001212", 17, 0, NULL, 0) = 17

Sometimes with different values of DATA this byte "c2" appears......always in the same position !! . After looking info trough internet, iknow that c2 is 194 in decimal and it doesn't look like a dangerous character like "\00" "\7f" could be.

Perhaps an error in c libraries of sockets??

This is my system : Linux 2.6.9-67
TCLInterpreter : 8.4

Plz Help me . THX!!

---------- Post updated 09-07-09 at 03:18 PM ---------- Previous update was 08-07-09 at 07:01 PM ----------

Nobody response.

I have fixed it !!!! exactly 20 hours after.

Par default a socket connection its created with "-encoding = utf-8" . But i was sending binary data, so sometimes (when my binary bytes matched up with a ascii code) it interpret that like some ascii char and the socket translated automatically to ascii code.
So the solution is to configure socket with "-encoding = binary".in tcl.
"fconfigure connection -encoding binary"

it was quite easy ....... like ever.

Thanks for sharing your experience

We appreciate...
All the best

:o i know...