利用Socket实现C++与Flex通信
利用Socket实现C++与Flex通信
一、C++服务器端
(用的是Visual Studio 2008(05,03的应该也可以,VC++的可能需要稍微改动))
代码如下:
#include <winsock2.h>
#include <stdio.h>
#include <windows.h>
#include <iostream>
using namespace std;
#pragma comment(lib,"ws2_32.lib")
void main(){
WORD wVersionRequested;
WSADATA wsaData;
int err;
short port=1300;//端口号
wVersionRequested = MAKEWORD( 1, 1 );
err = WSAStartup( wVersionRequested, &wsaData );//初始化套接字
if ( err != 0 )
{
return;
}
if ( LOBYTE( wsaData.wVersion ) != 1 || HIBYTE( wsaData.wVersion ) != 1 )
{
WSACleanup( );
return;
}
SOCKET sockSrv=socket(AF_INET,SOCK_STREAM,0);//创建套接字
SOCKET sockConn;//用来和客户端通信的套接字
SOCKADDR_IN addrSrv;//用来和客户端通信的套接字地址
addrSrv.sin_addr.S_un.S_addr=htonl(INADDR_ANY);
addrSrv.sin_family=AF_INET;
addrSrv.sin_port=htons(port);
bind(sockSrv,(SOCKADDR*)&addrSrv,sizeof(SOCKADDR));//绑定端口
listen(sockSrv,5);//侦听
printf("Server %d is listening......\n",port);
SOCKADDR_IN addrClient;
int len=sizeof(SOCKADDR);
char buf[4096];//接收的数据
char rbuf[100]="成功";//返回的数据
while(1)
{
//接受连接
sockConn=accept(sockSrv,(SOCKADDR*)&addrClient,&len);
printf("Accept connection from %s\n",inet_ntoa(addrClient.sin_addr));
//接收数据
int bytes;
if((bytes=recv(sockConn,buf,sizeof(buf),0))==
相关文档:
<?xml version="1.0" encoding="utf-8"?>
<!-- Simple example to demonstrate the DateTimeAxis class. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
import mx.collections.ArrayCollection;
......
对包含自定义命名空间的XML 进行分析是比较困难的, 它要求该命名空间一定要在任何XML 返回前被申明, 同时要在该命名空间内进行分析。比如对于以下的一个xml:
test.xml
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle= ......
毋庸置疑,PHP是一种非常棒的动态网页制作语言,他和C的极高相似性,使得它的语法学起来
很容易,他有很多类似C语言库函数的东西,还有像日期,字符串和时间函数等,这使得它很容
易开发相当复杂的应用程序。
当PHP应用到关键web站点上,如何保证质量将会变得很关键。然而,PHP并不是一 ......
While looking for information on the subject, I looked into the ONLamp article Extending Ruby with C by Garrett Rooney, the Extending Ruby chapter in the Pickaxe, README.EXT (located at /usr/share/doc/ruby1.8-dev/README.EXT.gz on my Ubuntu system) and got some help from Kjetil.
The resulting file c ......
最近在项目中遇到flex跨域访问的安全沙箱问题,查资料了解到需要在服务端加上crossdomain.xml文件,即:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-do ......