Sponsored Content
Top Forums Shell Programming and Scripting Writing in a socket trough TCL problem. Post 302352103 by trutoman on Thursday 10th of September 2009 11:20:29 AM
Old 09-10-2009
Writing in a socket trough TCL problem.

Hello everyone:

I have a script that writes and read DATA in/from a socket, but i have a great problem while writing.

My socket is created in this way:

Code:
  
set connection [socket -async $server $main_port]
fconfigure $connection -encoding binary -translation binary -blocking 1

And the writer procedure is this one:

Code:
  
proc p_send_data { DATA } {
  global connection
  
  puts -nonewline $connection $DATA
  flush $connection
}

This works, except when i call "p_send_data" many times and quickly (pej: while {1} {p_send_data "ksdjfksdf"}).

If my socket is in "blocking mode" , where is the problem??!! socket must remain blocked until it becomes writable, shouldn't it?

And tracing with "tcpdump" , "puts" command only works first and second time is called, after that, "puts" command is executed but it doesn't write anything in socket.

I have try also with my socket in "nonblocking mode" and writing in this way
Code:
fileevent $connection writable [puts $connection $DATA; flush $connection]

But the result is the same, the program "executes" all "puts" and "flush" instructions but there is not any trace with tcpdump .

Smilie


PD sorry for my english.
 

9 More Discussions You Might Find Interesting

1. HP-UX

Problem in HP-Unix while writing into socket

Our system is having a server and multiple clients. We are monitoring the client FDs using select() system call in HP-UX. After establishing connection-using socket with the remote client, before start sending the data we are checking the status of socket using select( ) call. For first 16... (0 Replies)
Discussion started by: AshokG
0 Replies

2. Shell Programming and Scripting

TCL Socket max Limit settting

How to set the max limit for socket opening TCL Thanks, Ajay (1 Reply)
Discussion started by: aju_kup
1 Replies

3. Programming

socket communication but not writing

hello, when i execute my code server side it connects with the client and when i try to write through the server into the client the program exits. i could not understand whether it is the problem with the server or with the client.The Protocol is TCP/IP. thanking you. (2 Replies)
Discussion started by: madfox
2 Replies

4. UNIX for Dummies Questions & Answers

problem with tk_optionmenu in tcl/tk

hi how can i see all and select one option from tk_optionMenu in tcl/tk using keyboard only. Thanks (0 Replies)
Discussion started by: pankajbgarh
0 Replies

5. Programming

Tcl - SOAP Problem

Hi, Im working with client side Tcl implementation on unix box of web services, to login to a tool with web service method written in C# on windows box and it is accessed by its link from the browser on unix box. Sorry that i have hidden the original names for security reasons. Using... (0 Replies)
Discussion started by: SankarV
0 Replies

6. Shell Programming and Scripting

tcl problem

I'm trying to write a script that will do the following: Open a text file for reading/writing. Read each line. When I find a specfic value in a line, append something to the end of that line. I loop through and read all the lines in myfile.txt looking for dev123_data_log and find a... (5 Replies)
Discussion started by: progkcp
5 Replies

7. UNIX for Advanced & Expert Users

connect problem for sctp socket (ipv6 socket) - Runtime fail Invalid Arguments

Hi, I was porting ipv4 application to ipv6; i was done with TCP transports. Now i am facing problem with SCTp transport at runtime. To test SCTP transport I am using following server and client socket programs. Server program runs fine, but client program fails giving Invalid Arguments for... (0 Replies)
Discussion started by: chandrutiptur
0 Replies

8. IP Networking

Writing a Socket Server

Hi All I have to design a server socket program.The requirement is Each connection from client will be in different threads. The challenge is Suppose Server is now connected with two client Client A and client B.They will be in two different thread. My application requirement is when... (4 Replies)
Discussion started by: mr_deb
4 Replies

9. UNIX for Advanced & Expert Users

Problem with TCL package

Following error encountered while executing characterizationEngine.tcl :confused::confused: $ ./characterizationEngine.tcl Tcl Client is running Ixia Software version: 5.60 Can't find tclx.tcl in the following directories: /usr/lib/tclX8.3 /usr/lib/tclX8.3 /usr/lib/tclX8.3... (0 Replies)
Discussion started by: hiten.r.chauhan
0 Replies
SOCKET_CONNECT(3)							 1							 SOCKET_CONNECT(3)

socket_connect - Initiates a connection on a socket

SYNOPSIS
bool socket_connect (resource $socket, string $address, [int $port]) DESCRIPTION
Initiate a connection to $address using the socket resource $socket, which must be a valid socket resource created with socket_create(3). PARAMETERS
o $socket - o $address - The $address parameter is either an IPv4 address in dotted-quad notation (e.g. 127.0.0.1) if $socket is AF_INET, a valid IPv6 address (e.g. ::1) if IPv6 support is enabled and $socket is AF_INET6 or the pathname of a Unix domain socket, if the socket fam- ily is AF_UNIX. o $port - The $port parameter is only used and is mandatory when connecting to an AF_INET or an AF_INET6 socket, and designates the port on the remote host to which a connection should be made. RETURN VALUES
Returns TRUE on success or FALSE on failure. The error code can be retrieved with socket_last_error(3). This code may be passed to socket_strerror(3) to get a textual explanation of the error. Note If the socket is non-blocking then this function returns FALSE with an error Operation now in progress. SEE ALSO
socket_bind(3), socket_listen(3), socket_create(3), socket_last_error(3), socket_strerror(3). PHP Documentation Group SOCKET_CONNECT(3)
All times are GMT -4. The time now is 01:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy