EasyManua.ls Logo

Case 8000 Series - Page 158

Case 8000 Series
162 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
/********************************************************************************************/
/* TITLE : Printer TELNET application */
/********************************************************************************************/
/* set #define constants for BSD_4_2+ ULTRIX*/
#include <sys/types/h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <netdb.h>
#include <stdio.h>
#include <signal.h>
#define DSTPORT 2000 /* Default TCP port number - dec. - 1 per app*/
#define NULADDR (struct sockaddr *) /* System assigns socket address */
#define TYPE SOCK_STREAM /* Sequenced, reliable two way connection */
#define LINGER_TIME 1
#define BUFF_SIZE 512
char buff[ BUFF_SIZE ]; /* Buffer to hold text in transit */
int newline = 0 ; /* non-zero(2 then 1) when CR RETURN found */
char previous = '\000'; /* remember the previous character */
int sock = -1; /* Socket descriptor (like a file descriptor */
char *progname; /* program name o/p with error messages */
int expand = 0; /* True when option to expand \r to \r\n selected */
main( argc, argv)
register int argc;
register char *argv[];
{
int size; /* Number of bytes in the buffer */
struct sockaddr_in addr; /* Describes socket connection */
struct linger optval; /* for setting socket option */
struct hostent *gethostbyname(), *raddr; /* For finding internet address */
interrupts() /* Be prepared for interrupts */
/* Verify the parameters and make a connection */
if ((argc < 2) || (argc > 4 ))
error( “Usage: %s host-name [port] [-n]” , argv[0] );
if (argc ==4)
{
if (strcmp(argv[3], ”-n”) )
error (”Usage: %s host-name [port] [-n]” , argv[0] );
else
expand = 1;
}
if ((argc == 3) && (strcmp(argv[2], ”-n”) == 0 ) )
expand = 1;
progname = argv[0];
if ((raddr = gethostbyname(argv[1]) ) == 0)
error(”Unknown host %s”, agrv[1] );
addr.sin_addr.s_addr = *((long *) raddr->h_addr);
X870-300351 Issue 1 H-2 Rev.0

Table of Contents

Related product manuals