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

📄 c.c

📁 一个免费的SMART CARD OS系统。
💻 C
字号:
/* ============================================================================	client test   ========================================================================= *//* */#include "platform.h"#include "socket.h"#include "exp_simumsg.h"short	gPort = 2000;void error( char * msg ){	printf("error: %s \n", msg);	exit(-1);}SOCKET	s;char*	atr;char select_mf[] = "00A40000023F00";char * card_response;int test_timeout(){	int ret;	char*	atr;	int timeout = 1; /* milliseconds */	/* test timeout */	ret = setsockopt(        s,        SOL_SOCKET,        SO_RCVTIMEO,        (char *)&timeout,        sizeof(timeout));	CHECK_ERRNO_SOCKET_ERROR( s, ret, "setsockopt timeout failed!" );	printf("\nTry to receive ATS with %d ms timeout : ", timeout);	if (receive_simumsg_from_card(s,&atr) != JY_OK) error("ats not received");	/* remove timeout */	timeout=0;	ret = setsockopt(        s,        SOL_SOCKET,        SO_RCVTIMEO,        (char *)&timeout,        sizeof(timeout));	CHECK_ERRNO_SOCKET_ERROR( s, ret, "setsockopt notimeout failed!" );	printf("\nwithout timeout : ");	/* hint: press the key on the server side to terminate it ;-) */	if (receive_simumsg_from_card(s,&atr) != JY_OK) error("atr not received");	printf("\n");	return 0;}int main(int argc, char ** argv){	if (argc > 1 && atoi( argv[1] ) ) {		gPort = atoi( argv[1] );	}	printf("client on port %d\n", gPort);	if (init_socket() != JY_OK) exit(-1);	if (JY_OK != connect_socket("127.0.0.1" ,gPort, &s)) exit(-1);	jlog( "reader", "send power on" );	if (JY_OK != send_simumsg_to_card(s,IF_TYPE_CONTACT,"POWERON")) exit(-1);	jlog( "reader", "receive atr" );	if (JY_OK != receive_simumsg_from_card(s,&atr)) exit(-1);	printf("receive ATR %s from the card\n",atr);	jlog( "reader", "send select mf" );	if (JY_OK != send_simumsg_to_card(s,IF_TYPE_CONTACT, select_mf)) exit(-1);	if (JY_OK != receive_simumsg_from_card(s,&card_response)) exit(-1);	printf("receive Card Response %s from the card\n",card_response);	if (JY_OK != send_simumsg_to_card(s,IF_TYPE_CONTACT,"POWEROFF")) exit(-1);	test_timeout();	printf("Closing socket\n");	if (JY_OK != close_socket(s)) error("socket not closed");	printf("Finishing socket\n");	if (JY_OK != done_socket()) error("socket not finished");	return 0;}

⌨️ 快捷键说明

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