Sponsored Content
Top Forums UNIX for Advanced & Expert Users "Phantom character" in Socket (RESOLVED) Post 302332247 by trutoman on Thursday 9th of July 2009 09:18:12 AM
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.
 

9 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

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

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

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

8. 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

9. 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
EVENTUTIL(3)								 1							      EVENTUTIL(3)

The EventUtil class

INTRODUCTION
EventUtil is a singleton with supplimentary methods and constants. CLASS SYNOPSIS
EventUtil final EventUtil Constants o const integer$EventUtil::AF_INET2 o const integer$EventUtil::AF_INET610 o const integer$EventUtil::AF_UNSPEC0 o const integer$EventUtil::LIBEVENT_VERSION_NUMBER33559808 o const integer$EventUtil::SO_DEBUG1 o const integer$EventUtil::SO_REUSEADDR2 o const integer$EventUtil::SO_KEEPALIVE9 o const integer$EventUtil::SO_DONTROUTE5 o const integer$EventUtil::SO_LINGER13 o const integer$EventUtil::SO_BROADCAST6 o const integer$EventUtil::SO_OOBINLINE10 o const integer$EventUtil::SO_SNDBUF7 o const integer$EventUtil::SO_RCVBUF8 o const integer$EventUtil::SO_SNDLOWAT19 o const integer$EventUtil::SO_RCVLOWAT18 o const integer$EventUtil::SO_SNDTIMEO21 o const integer$EventUtil::SO_RCVTIMEO20 o const integer$EventUtil::SO_TYPE3 o const integer$EventUtil::SO_ERROR4 o const integer$EventUtil::SOL_SOCKET1 o const integer$EventUtil::SOL_TCP6 o const integer$EventUtil::SOL_UDP17 o const integer$EventUtil::IPPROTO_IP0 o const integer$EventUtil::IPPROTO_IPV641 Methods o abstractpublic EventUtil::__construct (void ) o publicstatic int EventUtil::getLastSocketErrno NULL ([mixed $socket]) o publicstatic string EventUtil::getLastSocketError ([mixed $socket]) o publicstatic int EventUtil::getSocketFd (mixed $socket) o publicstatic bool EventUtil::getSocketName (mixed $socket, string &$address, [mixed &$port]) o publicstatic bool EventUtil::setSocketOption (mixed $socket, int $level, int $optname, mixed $optval) o publicstatic void EventUtil::sslRandPoll (void ) PREDEFINED CONSTANTS
o EventUtil::AF_INET - IPv4 address family o EventUtil::AF_INET6 - IPv6 address family o EventUtil::AF_UNSPEC - Unspecified IP address family o EventUtil::SO_DEBUG - Socket option. Enable socket debugging. Only allowed for processes with the CAP_NET_ADMIN capability or an effective user ID of 0 . (Added in event-1.6.0.) o EventUtil::SO_REUSEADDR - Socket option. Indicates that the rules used in validating addresses supplied in a bind(2) call should allow reuse of local addresses. See the socket(7) manual page. (Added in event-1.6.0.) o EventUtil::SO_KEEPALIVE - Socket option. Enable sending of keep-alive messages on connection-oriented sockets. Expects an integer boolean flag. See the socket(7) manual page. (Added in event-1.6.0.) o EventUtil::SO_DONTROUTE - Socket option. See the socket(7) manual page. (Added in event-1.6.0.) o EventUtil::SO_LINGER - Socket option. When enabled, a close(2) or shutdown(2) will not return until all queued messages for the socket have been successfully sent or the linger timeout has been reached. Otherwise, the call returns immediately and the closing is done in the background. See the socket(7) manual page. (Added in event-1.6.0.) o EventUtil::SO_BROADCAST - Socket option. Reports whether transmission of broadcast messages is supported. See the socket(7) manual page. (Added in event-1.6.0.) o EventUtil::SO_OOBINLINE - Socket option. See the socket(7) manual page. (Added in event-1.6.0.) o EventUtil::SO_SNDBUF - Socket option. See the socket(7) manual page. (Added in event-1.6.0.) o EventUtil::SO_RCVBUF - Socket option. See the socket(7) manual page. (Added in event-1.6.0.) o EventUtil::SO_SNDLOWAT - Socket option. See the socket(7) manual page. (Added in event-1.6.0.) o EventUtil::SO_RCVLOWAT - Socket option. See the socket(7) manual page. (Added in event-1.6.0.) o EventUtil::SO_SNDTIMEO - Socket option. See the socket(7) manual page. (Added in event-1.6.0.) o EventUtil::SO_RCVTIMEO - Socket option. See the socket(7) manual page. (Added in event-1.6.0.) o EventUtil::SO_TYPE - Socket option. See the socket(7) manual page. (Added in event-1.6.0.) o EventUtil::SO_ERROR - Socket option. See the socket(7) manual page. (Added in event-1.6.0.) o EventUtil::SOL_SOCKET - Socket option level. See the socket(7) manual page. (Added in event-1.6.0.) o EventUtil::SOL_TCP - Socket option level. See the socket(7) manual page. (Added in event-1.6.0.) o EventUtil::SOL_UDP - Socket option level. See the socket(7) manual page. (Added in event-1.6.0.) o EventUtil::IPPROTO_IP - See the socket(7) manual page. (Added in event-1.6.0.) o EventUtil::IPPROTO_IPV6 - See the socket(7) manual page. (Added in event-1.6.0.) o EventUtil::LIBEVENT_VERSION_NUMBER - Libevent' version number at the time when Event extension had been compiled with the library. PHP Documentation Group EVENTUTIL(3)
All times are GMT -4. The time now is 06:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy