Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
Protocol.cpp
Package: 1731.rar [view]
Upload User: swkcbjrc
Upload Date: 2016-04-02
Package Size: 45277k
Code Size: 2k
Category:
Game Program
Development Platform:
Visual C++
- // Protocol.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include "Protocol.h"
- #include "conio.h"
- #include "ProtocolFunc.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- #define CLIENT_CMDCONTENT "<CmdContent>"
- #define CLIENT_FROM "FromUserId"
- #define CLIENT_TO "ToUserId"
- #define CLIENT_CONTENT "Content"
- int main()
- {
- CString strBody="<Body> <CmdContent>FromUserId=Webmaster&ToUserId=chicken&Content=Hi,I need help;</CmdContent></Body>";
- CString strCmdContent;
- CString strKeyEnd;
- ProtocolFunc func;
- func.GetProtoLineEnd(CLIENT_CMDCONTENT,strKeyEnd);
- func.GetProtoContent(strBody,CLIENT_CMDCONTENT,strKeyEnd,strCmdContent);
- CPtrList listTemp;
- CString strSign=";";
- func.GetListBySign(strCmdContent,&listTemp,strSign);
- if(listTemp.GetCount()<=0)
- {
- func.ReleaseList(&listTemp);
- return 0;
- }
- POSITION pos=listTemp.FindIndex(0);
- LPNODESTRING pNodeString=(LPNODESTRING)listTemp.GetAt(pos);
- if(pNodeString==NULL)
- {
- func.ReleaseList(&listTemp);
- return 0;
- }
- strCmdContent=pNodeString->strContent;
- CPtrList listInfo;
- CString strMidSign="=";
- CString strEndSign="&";
- func.GetListByTwoSign(strCmdContent,&listInfo,strMidSign,strEndSign);
- CString strFrom,strTo,strContent;
- func.GetValueFromList(CLIENT_FROM,strFrom,&listInfo);
- func.GetValueFromList(CLIENT_TO,strTo,&listInfo);
- func.GetValueFromList(CLIENT_CONTENT,strContent,&listInfo);
- func.DeleteMateList(&listInfo);
- func.ReleaseList(&listTemp);
- printf("this is a test of get content from protocol:rn");
- printf("msg from %s to %s,content [%s]rn",strFrom,strTo,strContent);
- getch();
- return 0;
- }
- int SendMsg(CString strFrom,CString strTo,CString strContent)
- {
- ProtocolFunc func;
- CString strCmdContent;
- //增加content
- CPtrList MateList;
- LPNODEMATE pNodeMate=new NODEMATE;
- pNodeMate->strMateName =CLIENT_FROM;
- pNodeMate->strMateValue =strFrom;
- pNodeMate->strMateName =CLIENT_TO;
- pNodeMate->strMateValue =strTo;
- pNodeMate->strMateName =CLIENT_CONTENT;
- pNodeMate->strMateValue =strContent;
- MateList.AddTail(pNodeMate);
- func.ReplaceMateList(&MateList,strCmdContent);
- func.DeleteMateList(&MateList);
- //strCmdContent即为要发送的结构
- //send strCmdContent
- return 0;
- }