Exemplo n.º 1
0
int main()
{
	int ret = 0;
	void *handle = NULL;
	unsigned char buf[30] = { 0 };
	ret = cltSocketInit(&handle) ;
	if (ret != 0)
	{
		ITCAST_LOG(__FILE__, __LINE__, LogLevel[4], 0, "err on cltSocketInit()\n");
		goto End;
	}
	ret = clitSocket_setEncFunc(handle, MyEncData, NULL, 0);
	if (ret != 0)
	{
		ITCAST_LOG(__FILE__, __LINE__, LogLevel[4], 0, "err on clitSocket_setEncFunc()\n");
		goto End;
	}
	strcpy(buf, "abcdefghijklmn");
	ret = cltSocketSend(handle, buf, strlen(buf));
	if (ret != 0)
	{
		ITCAST_LOG(__FILE__, __LINE__, LogLevel[4], 0, "err on cltSocketSend()\n");
		goto End;
	}

	unsigned char *retBuf = NULL;
	int retBufLen = 0;
	ret = cltSocketRev(handle, &retBuf, &retBufLen);
	if (ret != 0)
	{
		ITCAST_LOG(__FILE__, __LINE__, LogLevel[4], 0, "err on cltSocketSend()\n");
		goto End;
	}
	printf("retBuf = [%s] and length = [%d]\n", retBuf, retBufLen);
	ret = cltSocketFreeBuf(&retBuf);
	if (ret != 0)
	{
		ITCAST_LOG(__FILE__, __LINE__, LogLevel[4], 0, "err on cltSocketFreeBuf()\n");
		goto End;
	}
End:
	if (handle != NULL)
	{
		cltSocketDestory(&handle/*in*/);
	}
	system("pause");

	return ret;
}
Exemplo n.º 2
0
//第一个API接口的测试
void main()
{
	int ret = 0;
	void *handle = NULL;
	unsigned char buf[128];
	int buflen = 11;
	unsigned char outbuf[128];
	int outlen;
	strcpy(buf,"aaaaadddddddd");
	//初始化环境
	ret = cltSocketInit(&handle);
	if (ret != 0)
	{
		printf("初始化失败 err %d\n",ret);
		goto END;
	}
	//发送数据
	ret = cltSocketSend(handle, buf, buflen);
	if (ret != 0)
	{
		printf("数据发送失败 err %d\n",ret );
		goto END;
	}

	ret = cltSocketRev(handle, outbuf, &outlen);
	if (ret != 0)
	{
		printf("数据接收失败 err %d\n", ret);
		goto END;
	}
	printf("outbuf =%s",outbuf);

END:
	//客户端释放资源
	if (handle != NULL)
	{
		cltSocketDestory(handle/*in*/);
	}

	ITCAST_LOG(__FILE__, __LINE__, LogLevel[0], 0, "dddddd");
	ITCAST_LOG(__FILE__, __LINE__, LogLevel[1], 1, "dddddd");
	ITCAST_LOG(__FILE__, __LINE__, LogLevel[2], 2, "dddddd");
	ITCAST_LOG(__FILE__, __LINE__, LogLevel[3], 3, "dddddd");
	ITCAST_LOG(__FILE__, __LINE__, LogLevel[4], 4, "dddddd");
	system("pause");
}
Exemplo n.º 3
0
int main()
{
	int  ret = 0;
	void *handle = NULL;
	unsigned char buff [20] = "asdfasdf";
	int bufflen = 0;
		bufflen = strlen(buff)+1;
	unsigned char buffrec[1024] ;
	int bufrecve = 0;
	printf("source buff = %s\n", buff);
	ret = cltSocketInit(&handle);
	if (ret != 0)
	{
		printf(" Initerror \n");
		return ret;
	}
	ret = cltSocketSend(handle /*in*/, buff /*in*/, bufflen /*in*/);
	if (ret != 0)
	{
		printf("cltSocketSend error \n");
		return ret;
	}
	ret = cltSocketRev(handle /*in*/, buffrec /*in*/, &bufrecve /*in out*/);
	if (ret != 0)
	{
		printf("cltSocketRev error \n");
		return ret;
	}
	printf("receve buff = %s\n", buffrec);
	ret =  cltSocketDestory(handle/*in*/);
	if (ret != 0)
	{
		printf("cltSocketDestory error \n");
		return ret;
	}

	system("pause");
	return 0;
}
Exemplo n.º 4
0
int main()
{
	int				rv = 0;
	void			*handle = NULL;
	unsigned char	buf[2048];
	int				buflen = 0;

	unsigned char	buf2[2048] = {0};
	int				buflen2 = 0;

	strcpy(buf, "aaaaaaaaaaaaaaaaaaaaaaaaafffffffffffffffffffffff");

	strcpy(NULL, "aaaaaaaaaaaaaaaaaaaaaaaaafffffffffffffffffffffff");


	buflen = 10;
	rv = cltSocketInit(&handle);
	if (rv != 0)
	{
		printf("func cltSocketInit():%d", rv);
		return rv;
	}
	
	
	// cvtres.exe
	rv = clitSocket_SetEncFunc(handle, myEncData2, NULL, 0);
	if (rv != 0)
	{
		printf("func cltSocketInit():%d", rv);
		goto End;
	}
	
	
	rv = cltSocketSend(handle, buf,  buflen);
	if (rv != 0)
	{
		printf("func cltSocketSend():%d", rv);
		goto End;
	}
	/*
	rv = cltSocketSend_enc(handle, buf,  buflen, myEncData, NULL, 0);
	if (rv != 0)
	{
		printf("func cltSocketSend_enc():%d", rv);
		goto End;
	}
	*/

	//设置解密函数入口地址,到框架中
	rv = clitSocket_SetDecFunc(handle, myDecData01, NULL, 0);
	if (rv != 0)
	{
		printf("func cltSocketInit():%d", rv);
		goto End;
	}


	rv = cltSocketRev(handle, buf2 , &buflen2);
	if (rv != 0)
	{
		printf("func cltSocketRev():%d", rv);
		goto End;
	}
	printf("\n%s", buf2);

End:

	rv = cltSocketDestory(handle);
	if (rv != 0)
	{
		printf("func cltSocketDestory():%d", rv);
		return rv;
	}

	printf("hello....\n");
	
	//system("pause");

	return 0;
}