Click here to Skip to main content
15,885,365 members
Home / Discussions / C#
   

C#

 
GeneralRe: reading magnetic card stripe Pin
OriginalGriff15-Jul-14 1:38
mveOriginalGriff15-Jul-14 1:38 
GeneralRe: reading magnetic card stripe Pin
Jassim Rahma15-Jul-14 1:39
Jassim Rahma15-Jul-14 1:39 
GeneralRe: reading magnetic card stripe Pin
Pete O'Hanlon15-Jul-14 1:49
mvePete O'Hanlon15-Jul-14 1:49 
AnswerRe: reading magnetic card stripe Pin
Gerry Schmitz15-Jul-14 9:18
mveGerry Schmitz15-Jul-14 9:18 
QuestionC# , Websocket -HTTPS Pin
sgeorge10615-Jul-14 0:49
sgeorge10615-Jul-14 0:49 
AnswerRe: C# , Websocket -HTTPS Pin
Pete O'Hanlon15-Jul-14 1:45
mvePete O'Hanlon15-Jul-14 1:45 
GeneralRe: C# , Websocket -HTTPS Pin
sgeorge10615-Jul-14 8:27
sgeorge10615-Jul-14 8:27 
QuestionIntegrating with Intelligent Networks Using MML in C# Pin
tnashc14-Jul-14 23:00
tnashc14-Jul-14 23:00 
I am working on a project where I have to integrate with an intelligent network using MML commands in C#. I have managed to connect to the target server using sockets. Now I want to transmit the appropriately formatted data to the server. That is to Encode the message then decode the response. I have code examples in C++ which I am finding quite cryptic.
Can anyone show me how I can implement this in C#
C++
#define MAX_LEN_VERSION 4
#define MAX_LEN_TERMINAL 8
#define MAX_LEN_SERVNAME 8
#define MAX_LEN_DLGCTRL 6
#define MAX_LEN_TXID 8
#define MAX_LEN_TXCTRL 6
#define MAX_LEN_TXRSVD 4
#define MAX_MSG_LEN 65536
#define MAX_HEAD_LEN 56
#define MSG_STARTTAG_LEN 4
#define MSG_INFOLEN_LEN 4
#define MSG_CHKSUM_LEN 4
#define MSG_COMM_LEN 12
#define MAX_HB_MSG_LEN 4
#define MAX_HB_CONTENT_LEN 4
#define MAX_HB_CHCKSUM 4
#define HB_MSG_LEN 16
#define MAX_LEN_DLGID 8
#define MAX_LEN_DLGRSVD 4
#define MSG_STARTTAG "\x1C\x1D\x1E\x1F"
#define MSG_VERSION "1.00"
#define MSG_TERMINAL "internal"
#define MSG_TXRSVD " "
#define MSG_DLGRSVD " "
#define HB_CONTENT "HBHB"

EnRet Encode(MsgInfo & sendMsg, char * sendBuff, int & sendLen, int send_type)
		{
			//The exception handling is omitted.
				//The method of encoding a heartbeat message is as follows:
				if (TYPE_OF_HB_MSG == send_type)
				{
				int temp_len;
				char * p_num, hb_checksum[MAX_HB_CHCKSUM];
				temp_len = 0;
				strncpy(sendBuff + temp_len, MSG_STARTTAG, MSG_STARTTAG_LEN);
				temp_len += MSG_STARTTAG_LEN;
				p_num = Int2ToHex(HB_MSG_LEN);
				strncpy(sendBuff + temp_len, p_num, MAX_HB_MSG_LEN);
				temp_len += MAX_HB_MSG_LEN;
				strncpy(sendBuff + temp_len, HB_CONTENT, MAX_HB_CONTENT_LEN);
				temp_len = MSG_STARTTAG_LEN + MAX_HB_MSG_LEN;
				GetChkSum(MAX_HB_MSG_LEN, sendBuff + temp_len, hb_checksum);
				temp_len = HB_MSG_LEN - MAX_HB_CHCKSUM;
				strncpy(sendBuff + temp_len, hb_checksum, MAX_HB_CHCKSUM);
				printf("\ncode HB secceed!\n%s", sendBuff);
				return Success;
				}
			//The method of encoding an ordinary message is as follows:
			Int msglen, cmdlen, len;
			char *p, chksum[MSG_CHKSUM_LEN];
			char *pTx[] = { "TXBEG", "TXCON", "TXCAN", "TXEND" };
			char *pDlg[] = { "DLGLGN", "DLGBEG", "DLGCON", "DLGEND" };
			//Printing the message sent by the Provision.
			PrintMsg(sendMsg);
			//Counting the length of a message.
			cmdlen = strlen(sendMsg.cmd);
			msglen = MAX_HEAD_LEN + cmdlen;
			len = (4 - msglen % 4);
			msglen += len;
			sendLen = msglen + MSG_COMM_LEN;
			memset(sendBuff, ' ', MAX_MSG_LEN);
			len = 0;
			//Encapsulating Start flag.
			strncpy(sendBuff + len, MSG_STARTTAG, MSG_STARTTAG_LEN);
			len += MSG_STARTTAG_LEN;
			//Encapsulating Size
			p = Int2ToHex(msglen);
			strncpy(sendBuff + len, p, MSG_INFOLEN_LEN);
			len += MSG_INFOLEN_LEN;
			//Encapsulating Message header.
			strncpy(sendBuff + len, MSG_VERSION, MAX_LEN_VERSION);
			len += MAX_LEN_VERSION;
			strncpy(sendBuff + len, MSG_TERMINAL, MAX_LEN_TERMINAL);
			len += MAX_LEN_TERMINAL;
			strncpy(sendBuff + len, sendMsg.service, strlen(sendMsg.service));
			len += MAX_LEN_SERVNAME;
			//Encapsulating Session header.
			p = Int4ToHex(sendMsg.snLogin);
			strncpy(sendBuff + len, p, MAX_LEN_DLGID);
			len += MAX_LEN_DLGID;
			strncpy(sendBuff + len, pDlg[sendMsg.dlgCtrl], strlen(pDlg[sendMsg.dlgCtrl]));
			len += MAX_LEN_DLGCTRL;
			strncpy(sendBuff + len, MSG_DLGRSVD, MAX_LEN_DLGRSVD);
			len += MAX_LEN_DLGRSVD;
			//Encapsulating Transaction header.
			p = Int4ToHex(sendMsg.sequence);
			strncpy(sendBuff + len, p, MAX_LEN_TXID);
			len += MAX_LEN_TXID;
			strncpy(sendBuff + len, pTx[sendMsg.txCtrl], strlen(pTx[sendMsg
				.txCtrl]));
			len += MAX_LEN_TXCTRL;
			strncpy(sendBuff + len, MSG_TXRSVD, MAX_LEN_TXRSVD);
			len += MAX_LEN_TXRSVD;
			//Encapsulating Operation information.
			strncpy(sendBuff + len, sendMsg.cmd, cmdlen);
			//Encapsulating Checksum.
			len = MSG_STARTTAG_LEN + MSG_INFOLEN_LEN;
			GetChkSum(msglen, sendBuff + len, chksum);
			len = sendLen - MSG_CHKSUM_LEN;
			strncpy(sendBuff + len, chksum, MSG_CHKSUM_LEN);
			return Success;
		}

SuggestionRe: Integrating with Intelligent Networks Using MML in C# Pin
Richard MacCutchan14-Jul-14 23:41
mveRichard MacCutchan14-Jul-14 23:41 
QuestionRefactoring versus Performance Pin
Agent__00714-Jul-14 19:42
professionalAgent__00714-Jul-14 19:42 
AnswerRe: Refactoring versus Performance Pin
Bernhard Hiller14-Jul-14 20:36
Bernhard Hiller14-Jul-14 20:36 
GeneralRe: Refactoring versus Performance Pin
Agent__00714-Jul-14 20:55
professionalAgent__00714-Jul-14 20:55 
AnswerRe: Refactoring versus Performance Pin
Kornfeld Eliyahu Peter14-Jul-14 21:35
professionalKornfeld Eliyahu Peter14-Jul-14 21:35 
GeneralRe: Refactoring versus Performance Pin
Agent__00714-Jul-14 21:49
professionalAgent__00714-Jul-14 21:49 
GeneralRe: Refactoring versus Performance Pin
OriginalGriff14-Jul-14 21:49
mveOriginalGriff14-Jul-14 21:49 
AnswerRe: Refactoring versus Performance Pin
OriginalGriff14-Jul-14 21:03
mveOriginalGriff14-Jul-14 21:03 
GeneralRe: Refactoring versus Performance Pin
Agent__00714-Jul-14 21:45
professionalAgent__00714-Jul-14 21:45 
GeneralRe: Refactoring versus Performance Pin
Rob Philpott14-Jul-14 21:48
Rob Philpott14-Jul-14 21:48 
GeneralRe: Refactoring versus Performance Pin
OriginalGriff14-Jul-14 21:53
mveOriginalGriff14-Jul-14 21:53 
GeneralRe: Refactoring versus Performance Pin
Rob Philpott14-Jul-14 22:12
Rob Philpott14-Jul-14 22:12 
GeneralRe: Refactoring versus Performance Pin
OriginalGriff14-Jul-14 22:45
mveOriginalGriff14-Jul-14 22:45 
GeneralRe: Refactoring versus Performance Pin
Rob Philpott14-Jul-14 22:54
Rob Philpott14-Jul-14 22:54 
GeneralRe: Refactoring versus Performance Pin
Rob Philpott14-Jul-14 22:28
Rob Philpott14-Jul-14 22:28 
GeneralRe: Refactoring versus Performance Pin
OriginalGriff14-Jul-14 22:38
mveOriginalGriff14-Jul-14 22:38 
GeneralRe: Refactoring versus Performance Pin
Agent__00714-Jul-14 22:14
professionalAgent__00714-Jul-14 22:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.