AT&T Home | AT&T Labs | Research
AT&T Labs, Inc. - Research

The Yoix® Scripting Language

Home | What's New | Grammar | Documentation | Download | License | YChart | YDAT | YWAIT | Byzgraf | FAQs
send (Object socket, String buf [, String addr, int port]) yoix.net
 
Uses socket, which should be a DatagramSocket or a MulticastSocket, to send the contents of buf to a remote system and returns the number of bytes sent or -1 if there was an error. Nothing is sent and 0 is returned if buf is NULL or the empty string (i.e., ""). send automatically activates socket if it is not alive.

If socket is connected to a remote system then send can only send packets to that address and port, which means the optional addr and port arguments should be omitted. If socket is not connected to a remote system then send must be told where buf should go using the addr and port arguments. addr should be an IP address, a name that can be resolved by DNS, or NULL which is a convenient way to refer to the local host. port should be an integer between 0 to 65535, inclusive.
 
 Example:   The program,
import yoix.*.*;

DatagramSocket ds;
int count;

count = send(ds, "This is a test", "127.0.0.1", 7);
printf("send returned %d\n", count);
tries to send 14 characters to port 7 on your local host, which should just throw them away. See the DatagramSocket documentation for another example.
 
 Return:   int
 
 See Also:   accept, DatagramSocket, MulticastSocket, receive, ServerSocket, Socket

 

Yoix is a registered trademark of AT&T Inc.