Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

TCP£¨SOCKETS£©±à³Ì C/C++ʵÏÖ

ͨÐÅ
Server£º
#pragma comment(lib, "ws2_32.lib")
#include <Winsock2.h>
#include <stdio.h>

void main()
{
//°æ±¾Ð­ÉÌ
WORD wVersionRequested;
WSADATA wsaData;
int err;

wVersionRequested = MAKEWORD(1,1); //0x0101
err = WSAStartup(wVersionRequested,&wsaData);

if(err!=0)
{
return 0;
}

if(LOBYTE(wsaData.wVersion)!=1 || HIBYTE(wsaData.wVersion)!=1) //wsaData.wVersion!=0x0101
{
WSACleanup();
return 0;
}

//´´½¨Socket
SOCKET sockSvr = socket(AF_INET,SOCK_STREAM,0);

//´´½¨IPµØÖ·ºÍ¶Ë¿Ú
SOCKADDR_IN addrSvr;

addrSvr.sin_addr.S_un.S_addr = htonl(INADDR_ANY);
addrSvr.sin_family = AF_INET;
addrSvr.sin_port = htons(6000);

//°ó¶¨¶Ë¿Ú¼àÌý
bind(sockSvr,(SOCKADDR*)&addrSvr,sizeof(SOCKADDR));
listen(sockSvr,5);

sockaddr_in addrClient;
int len = sizeof(sockaddr);

while(true)
{
//×èÈû·½·¨£¬»ñµÃÒ»¸ö¿Í»§SocketÁ¬½Ó
SOCKET sockConn = accept(sockSvr,(sockaddr*)&addrClient,&len);
char sendbuffer[128];
sprintf(sendbuffer,"Welcom %s!",inet_ntoa(addrClient.sin_addr));

//Ïò¿Í»§Socket·¢ËÍÊý¾Ý
send(sockConn,sendbuffer,strlen(sendbuffer)+1,0);
char recvbuffer[128];

//´Ó¿Í»§Soc½ÓÊÜÊý¾Ý
recv(sockConn,recvbuffer,128,0);
printf("%s\n",recvbuffer);

//¹Ø±ÕSocket
closesocket(sockConn);
}

closesocket(sockSvr);

//ÊÍ·ÅWinsock×ÊÔ´
WSACleanup();
return 0;
}
client£º
#pragma comment (lib,"ws2_32.lib")
#include <Winsock2.h>
#include <stdio.h>

void main()
{
//°æ±¾Ð­ÉÌ
WORD wVersionRequested;
WSADATA wsaData;
int err;
wVersionRequested = MAKEWORD(1,1); //0x0101
err = WSAStar


Ïà¹ØÎĵµ£º

¡¾C\C++ÓïÑÔÈëÃÅƪ¡¿ λÔËËã


»Ø¹Ë֮ǰµÄƪ·ù£¬CÓïÑÔµÄÖ÷Ì岿·Ö»ù±¾ÒѾ­½éÉÜÍêÁË¡£Ö®ËùÒÔûÓнéÉÜC++µÄÏà¹ØÌØÐÔÊÇÒòΪÔÚ֮ǰµÄÎÄÕÂÖÐCºÍC++ÔÚÕâЩ·½Ã涼Óй²ÐÔ£¬ËùÒÔÔÚÃæÏò¶ÔÏó֮ǰ¡£ÎÒÃÇÏÈ°ÑÕâЩ¹²ÐÔ¸ø½éÉÜÍê¡£Ò²¾ÍÊÇ˵ÔÚ½éÉÜÃæÏò¶ÔÏó֮ǰ£¬ËùÓеÄÎÄÕ¶¼ÊÇCC++Öж¼ÄÜʹÓõġ£´ÓÕâµãÉÏÀ´¿´£¬ÏÖÔÚÕý¼«Á¦·Ü¶·ÓÚC++Õ½ÏßÉϵijõѧÕß»¹ÊǺÜÓÐÓô¦µÄ¡£
±¾Æª¼ ......

c/c++Í·Îļþ£¬±£´æ£¬±¸ÓÃ

 
C¡¢´«Í³ C++
#include <stdio.h>¡¡¡¡¡¡¡¡ //¶¨ÒåÊäÈ룯Êä³öº¯Êý
#include <stdlib.h>¡¡¡¡¡¡¡¡//¶¨ÒåÔÓÏÊý¼°ÄÚ´æ·ÖÅ亯Êý
#include <string.h>¡¡¡¡¡¡¡¡//×Ö·û´®´¦Àí
#include <assert.h>¡¡¡¡¡¡¡¡//É趨²åÈëµã
#include <ctype.h>¡¡¡¡¡¡¡¡ //×Ö·û´¦Àí
#include <errno.h&g ......

CºÍC++µÄµãµÎ»ýÀÛ£¨1£©

                     CºÍC++µÄµãµÎ»ýÀÛ£¨1£©
1. mfc ±à³ÌÖдæÔÚ×ÅÈç¹û³öÏÖ“ÄÚ´æ²»×㔵ĶԻ°¿ò£¬Ò»ÖÖÇé¿öÊÇÔÚÉêÇëÄÚ´æµÄʱºò³öÏÖÎÊÌ⣬Ҳ¾ÍÊÇÀýÈ磺char *pChar = new char[num]; µ«´Ëʱnum ΪÁã»òÕ߸º ......

C/C++ ³ÌÐòÉè¼ÆԱӦƸ³£¼ûÃæÊÔÊÔÌâÉîÈëÆÊÎö

1.ÒýÑÔ
¡¡¡¡±¾ÎĵÄд×÷Ä¿µÄ²¢²»ÔÚÓÚÌṩC/C++³ÌÐòÔ±ÇóÖ°ÃæÊÔÖ¸µ¼£¬¶øÖ¼ÔÚ´Ó¼¼ÊõÉÏ·ÖÎöÃæÊÔÌâµÄÄÚº­¡£ÎÄÖеĴó¶àÊýÃæÊÔÌâÀ´×Ô¸÷´óÂÛ̳£¬²¿·ÖÊÔÌâ½â´ðÒ²²Î¿¼ÁËÍøÓѵÄÒâ¼û¡£
¡¡¡¡Ðí¶àÃæÊÔÌâ¿´ËƼòµ¥£¬È´ÐèÒªÉîºñµÄ»ù±¾¹¦²ÅÄܸø³öÍêÃÀµÄ½â´ð¡£ÆóÒµÒªÇóÃæÊÔÕßдһ¸ö×î¼òµ¥µÄstrcpyº¯Êý¶¼¿É¿´³öÃæÊÔÕßÔÚ¼¼ÊõÉϾ¿¾¹´ïµ½ÁËÔõÑùµÄ ......

VC++·ÃÎÊjavascriptµÄϵÁÐÎÄÕÂ

ÓÐЩÍøÓѾ­³£Ñ¯ÎÊ£ºÔÚVC++ÖÐÈçºÎ·ÃÎÊjavascriptÖеĶÔÏ󡢺¯Êý¡¢±äÁ¿µÈÔªËØ£¿
ÕâÀï°ÑÒÔÇ°·¢±íµÄһϵÁÐÎÄÕ¼¯ÖÐÔÚÒ»Æ𣬷½±ã²éÔÄ¡£
vc++·ÃÎÊjavascript(1)--windowÔڽű¾ÒýÇæÖеÄ×÷Óà
http://blog.csdn.net/pimshell/archive/2008/08/02/2758863.aspx
vc++·ÃÎÊjavascript(2)--IDispatchExÊǶ¯Ì¬½Å±¾ÓïÑԵĻù´¡&nb ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ