⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 simpcl.c

📁 tuxede下面的编程
💻 C
字号:
#include <stdio.h>#include "atmi.h"		/* TUXEDO  Header File *//*myfunc must be defined as below,other define is error*/void _TMDLLENTRY myfunc(char *buffer,long len,long flag){	long len2;	char buftype[20],subtype[20];	if ((len2=tptypes(buffer,buftype,subtype))<0)	{		printf("invalid buffer receive;\n");	}	else if(!strcmp(buftype,"STRING"))	{		printf("unsolicited message from server:%s,len=%d,flag=%d\n",buffer);	}	else	printf("cannot printout buffer\n");}#if defined(__STDC__) || defined(__cplusplus)main(int argc, char *argv[])#elsemain(argc, argv)int argc;char *argv[];#endif{	char *sendbuf, *rcvbuf;	long sendlen, rcvlen;	char *sss;	int ret;	int i;	char buftype[20],subtype[20];	TPINIT *tpinfo=NULL;;			if(argc != 2) 	{		(void) fprintf(stderr, "Usage: simpcl string\n");		exit(1);	}		tpinfo =(TPINIT*)tpalloc("TPINIT",NULL,TPINITNEED(0));	if (tpinfo == (TPINIT*)NULL)	{		fprintf(stderr,"unable to allocate TPINIT buffer\n");		exit(1);	}	strcpy(tpinfo->usrname,"notify");	strcpy(tpinfo->cltname,"xcjclient");	//strcpy(tpinfo->passwd,"isme");	//strcpy(tpinfo->grpname,"xcjgroup");	tpinfo->flags=TPU_DIP;/*TPU_IGN,TPU_DIP,TPU_SIG(the default is TUP_DIP?)*/	//strcpy ((char *)&tpinfo->data, "isme");	//tpinfo->datalen = strlen((char *)&tpinfo->data)+1L;	/* Attach to System/T as a Client Process */	if (tpinit(tpinfo) == -1) 	{		(void) fprintf(stderr, "Tpinit failed\n");		 exit(1);	}	sendlen = strlen(argv[1]);	/* Allocate STRING buffers for the request and the reply */	if((sendbuf = (char *) tpalloc("STRING", NULL, sendlen+1)) == NULL) 	{		(void) fprintf(stderr,"Error allocating send buffer\n");		tpterm();		exit(1);	}	if((rcvbuf = (char *) tpalloc("STRING", NULL, sendlen+1)) == NULL) {		(void) fprintf(stderr,"Error allocating receive buffer\n");		tpfree(sendbuf);		tpterm();		exit(1);	}	printf("@@@@@@@@@\n");	if(tpsetunsol(myfunc)== TPUNSOLERR)	{		printf("tpsetunsol() failure:%s\n",tpstrerror(tperrno));		tpfree(sendbuf);		tpfree(rcvbuf);		tpterm();		exit(1);		}			(void) strcpy(sendbuf, argv[1]);	printf("11111111\n");	/* Request the service TOUPPER, waiting for a reply */	ret = tpcall("TOUPPER", (char *)sendbuf, 0, (char **)&rcvbuf, &rcvlen, (long)0);	if(ret == -1) 	{		fprintf(stderr, "Can't send request to service TOUPPER:%s\n",tpstrerror(tperrno));		tpfree(sendbuf);		tpfree(rcvbuf);		tpterm();		exit(1);	}	printf("111\n");	(void) fprintf(stdout, "Returned string is: %s\n", rcvbuf);	while(1)	{		 /*if call tpstrerror(0); will not get the message*/		 /* if donot call ATMI function here. the server also		 send* message to this client. when CTRL+C to end this		 process. will print the message*/		 tptypes(sendbuf,buftype,subtype);			}	printf("222\n");	/* Free Buffers & Detach from System/T */	tpfree(sendbuf);	tpfree(rcvbuf);	tpterm();	printf("333\n");	return(0);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -