send(3Tk) send(3Tk)
send - Execute a command in a different application
send ?options? app cmd ?arg arg ...? |
This command arranges for cmd (and args) to be executed in the
application named by app. It returns the result or error from that
command execution. App may be the name of any application whose main
window is on the display containing the sender's main window; it need
not be within the same process. If no arg arguments are present, then
the command to be executed is contained entirely within the cmd argument.
If one or more args are present, they are concatenated to form the
command to be executed, just as for the eval command.
If the initial arguments of the command begin with ``-'' they are treated
as options. The following options are currently defined:
-async
Requests asynchronous invocation. In this case the send command |
will complete immediately without waiting for cmd to complete in the|
target application. If the target application is in the same |
process as the sending application then the -async option is |
ignored.
-displayof pathName
Specifies that the target application's main window is on the |
display of the window given by pathName, instead of the display |
containing the application's main window.
-- Serves no purpose except to terminate the list of options. This |
option is needed only if app could contain a leading ``-'' |
character.
The name of an application is set initially from the name of the program
or script that created the application. You can query and change the
name of an application with the tk appname command.
If the send command is removed from an application (e.g. with the
command rename send {}) then the application will not respond to incoming
send requests anymore, nor will it be able to issue outgoing requests.
Communication can be reenabled by invoking the tk appname command.
Page 1
send(3Tk) send(3Tk)
The send command is potentially a serious security loophole, since any
application that can connect to your X server can send scripts to your
applications. These incoming scripts can use Tcl to read and write your
files and invoke subprocesses under your name. Host-based access control
such as that provided by xhost is particularly insecure, since it allows
anyone with an account on particular hosts to connect to your server, and
if disabled it allows anyone anywhere to connect to your server. In
order to provide at least a small amount of security, Tk checks the
access control being used by the server and rejects incoming sends unless
(a) xhost-style access control is enabled (i.e. only certain hosts can
establish connections) and (b) the list of enabled hosts is empty. This
means that applications cannot connect to your server unless they use
some other form of authorization such as that provide by xauth.
application, name, remote execution, security, send
send(3N) send(3N)
send, sendto, sendmsg - send a message from a socket
#include <sys/types.h>
int send(int s, char *msg, int len, int flags);
int sendto(int s, char *msg, int len, int flags, caddr_t to,
int tolen);
int sendmsg(int s, msghdr *msg, int flags);
s is a socket created with socket. send, sendto, and sendmsg are used to
transmit a message to another socket. send may be used only when the
socket is in a connected state, while sendto and sendmsg may be used at
any time.
The address of the target is given by to with tolen specifying its size.
The length of the message is given by len. If the message is too long to
pass atomically through the underlying protocol, then the error EMSGSIZE
is returned, and the message is not transmitted.
No indication of failure to deliver is implicit in a send. Return values
of -1 indicate some locally detected errors.
If no buffer space is available at the socket to hold the message to be
transmitted, then send normally blocks, unless the socket has been placed
in non-blocking I/O mode [see fcntl(2)]. The select call may be used to
determine when it is possible to send more data.
The flags parameter is formed by ORing one or more of the following:
MSG_OOB Send out-of-band data on sockets that support this notion. The
underlying protocol must also support out-of-band data.
Currently, only SOCK_STREAM sockets created in the AF_INET
address family support out-of-band data.
MSG_DONTROUTE
The SO_DONTROUTE option is turned on for the duration of the
operation. It is used only by diagnostic or routing programs.
See recv(3N) for a description of the msghdr structure.
These calls return the number of bytes sent, or -1 if an error occurred.
The calls fail if:
Page 1
send(3N) send(3N)
EBADF s is an invalid descriptor.
ENOTSOCK s is a descriptor for a file, not a socket.
EINVAL tolen is not the size of a valid address for the
specified address family.
EINTR The operation was interrupted by delivery of a signal
before any data could be buffered to be sent.
EMSGSIZE The socket requires that message be sent atomically,
and the message was too long.
EWOULDBLOCK The socket is marked non-blocking and the requested
operation would block.
ENOMEM There was insufficient user memory available for the
operation to complete.
ENOSR There were insufficient STREAMS resources available
for the operation to complete.
fcntl(2), write(2), connect(3N), getsockopt(3N), recv(3N), socket(3N)
The type of address structure passed to accept depends on the address
family. UNIX domain sockets (address family AF_UNIX) require a
socketaddr_un structure as defined in sys/un.h; Internet domain sockets
(address family AF_INET) require a sockaddr_in structure as defined in
netinet/in.h. Other address families may require other structures. Use
the structure appropriate to the address family; cast the structure
address to a generic caddr_t in the call to send and pass the size of the
structure in the tolen argument.
PPPPaaaaggggeeee 2222 [ Back ]
|