"Phantom character" in Socket (RESOLVED)


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users "Phantom character" in Socket (RESOLVED)
# 1  
Old 07-09-2009
"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:
Code:
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:

Code:
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.
# 2  
Old 07-09-2009
Thanks for sharing your experience

We appreciate...
All the best
# 3  
Old 07-10-2009
Smilie i know...
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. Post Here to Contact Site Administrators and Moderators

Marking thread "Resolved"

Can the OP of a thread still mark the thread "Resolved" when the question is answered? (2 Replies)
Discussion started by: wbport
2 Replies

3. UNIX for Advanced & Expert Users

"Phantom" overwrite with dd on sda*?

Greetings. Just wondering about a little "quirk" which I seem to have found when using dd ;) (FWIW on that note, I'm using a flash install of Parted Magic to run dd in these tests...) Thinking about it, there should be some measurable excitement associated withdd if=/dev/zero of=/dev/sda*... (4 Replies)
Discussion started by: LinQ
4 Replies

4. Shell Programming and Scripting

Using sed to find text between a "string " and character ","

Hello everyone Sorry I have to add another sed question. I am searching a log file and need only the first 2 occurances of text which comes after (note the space) "string " and before a ",". I have tried sed -n 's/.*string \(*\),.*/\1/p' filewith some, but limited success. This gives out all... (10 Replies)
Discussion started by: haggismn
10 Replies

5. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

6. Shell Programming and Scripting

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

7. UNIX for Advanced & Expert Users

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

8. UNIX for Dummies Questions & Answers

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

9. Shell Programming and Scripting

removing the "\" and "\n" character using sed or tr

Hi All, I'm trying to write a ksh script to parse a file. When the "\" character is encountered, it should be removed and the next line should be concatenated with the current line. For example... this is a test line #1\ should be concatenated with line #2\ and line number 3 when this... (3 Replies)
Discussion started by: newbie_coder
3 Replies
Login or Register to Ask a Question