Sends a message to a User Datagram Protocol (UDP) port.
sp_sendmsg ip_address, port_number, message
is the IP address of the machine where the UDP application is running.
is the port number of the UDP port.
is the message to send. It can be up to 255 characters in length.
sp_sendmsg "120.10.20.5", 3456, "Hello World"
sp_sendmsg is not supported on Windows NT.
To enable the use of UDP messaging, a System Security Officer must set the configuration parameter allow sendmsg to 1.
No security checks are performed with sp_sendmsg. Sybase strongly recommends caution when using sp_sendmsg to send sensitive information across the network. By enabling this functionality, the user accepts any security problems which result from its use.
This sample C program listens on a port that you specify and echoes the messages it receives. For example, to receive the sp_sendmsg calls for Example 1, use:
updmon 3456 #include <stdlib.h> #include <stdio.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <unistd.h> #include <fcntl.h> main(argc, argv) int argc; char *argv[]; { struct sockaddr_in sadr; int portnum,sck,dummy,msglen; char msg[256]; if (argc < 2) { printf(“Usage: udpmon <udp portnum>\n”); exit(1); } if ((portnum=atoi(argv[1])) < 1) { printf(“Invalid udp portnum\n”); exit(1); } if ((sck=socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP)) < 0) { printf(“Couldn’t create socket\n”); exit(1); } sadr.sin_family = AF_INET; sadr.sin_addr.s_addr = inet_addr(“0.0.0.0”); sadr.sin_port = portnum; if (bind(sck,&sadr,sizeof(sadr)) < 0) { printf(“Couldn’t bind requested udp port\n”); exit(1); } for (;;) { if((msglen=recvfrom(sck,msg,sizeof(msg),0,NULL,&dummy)) < 0) printf(“Couldn’t recvfrom() from udp port\n”); printf(“%.*s\n”, msglen, msg); } }
Any user can execute sp_sendmsg.
Function syb_sendmsg