ÀûÓÃ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))==
Ïà¹ØÎĵµ£º
ϵͳ»·¾³£ºWindows 7
Èí¼þ»·¾³£ºVisual C++ 2008 SP1 +SQL Server 2005
±¾´ÎÄ¿µÄ£º±àдһ¸öº½¿Õ¹ÜÀíϵͳ
ÕâÊÇÊý¾Ý¿â¿Î³ÌÉè¼ÆµÄ³É¹û£¬ËäÈ»³É¼¨²»¼Ñ£¬µ«ÊÇ×÷ΪÎÒÓÃVC++ ÒÔÀ´±àдµÄ×î´ó³ÌÐò»¹ÊÇ´«µ½ÍøÉÏ£¬ÒÔ¹©²Î¿¼¡£ÓÃVC++ ×öÊý¾Ý¿âÉè¼Æ²¢²»ÈÝÒ×£¬µ«Ò²²»ÊDz»¿ÉÄÜ¡£ÒÔÏÂÊÇÎҵijÌÐò½çÃ棬ºóÃæ ......
C·ç¸ñ×Ö·û´®£º¶Ô×Ö·û´®½øÐвÙ×÷µÄ C º¯Êý¶¨ÒåÔÚÍ·Îļþ<cstring>ÖУ»
1. ×Ö·û´®¶¨Ò壺char* result£»
2. ×Ö·û´®µÄ×îºóÒ»¸ö×Ö·ûÊÇnull×Ö·û£¨'\0'£©£¬¿ÉÒÔͨ¹ýÕâ¸ö×Ö·ûÈ·¶¨×Ö·û´®µÄ½áβ¡£
3. strlen()·µ»ØµÄÊÇ×Ö·û´®µÄ´óС£»Òò´Ë£¬ ......
ʹÓÃC/C++À©Õ¹Python
·Òë:
gashero
Èç¹ûÄã»áÓÃC£¬ÊµÏÖPythonǶÈëÄ£¿éºÜ¼òµ¥¡£ÀûÓÃÀ©Õ¹Ä£¿é¿É×öºÜ¶àPython²»·½±ã×öµÄÊÂÇ飬ËûÃÇ¿ÉÒÔÖ±½Óµ÷ÓÃC¿âºÍϵͳµ÷Óá£
ΪÁËÖ§³ÖÀ©Õ¹£¬Python API¶¨ÒåÁËһϵÁк¯Êý¡¢ºêºÍ±äÁ¿£¬ÌṩÁ˶ÔPythonÔËÐÐʱϵͳµÄ·ÃÎÊÖ§³Ö¡£PythonµÄC APIÓÉCÔ´Âë×é³É£¬²¢°üº¬ “Python.h” Í·Îļ ......
#include < ruby.h > //
static int id_sum;
int Values[] = {5, 10 ,15,-1,20,0};
static VALUE wrap_sum(VALUE args)
{
VALUE * values = (VALUE *) args;
VALUE summer = values[0];
VALUE max = values[1];
return rb_funcall(summer,id_sum,1,max);
}
static VALUE ......
.h Îļþ
class CHtmlSkinDlg : public CDHtmlDialog
{
¡£¡£¡£¡£¡£
DECLARE_DISPATCH_MAP()
// !!! ¸²¸Ç»ùÀàµÄÕâ¸ö·½·¨
BOOL CanAccessExternal()
{
......