#include<iostream>  
#include<Winsock2.h>  
#pragma comment(lib,"WS2_32.lib")   
using namespace std;  
void main()  
{  
    WORD wVersionRequested;  
    WSADATA wsaData;  
    int err;  
    wVersionRequested = MAKEWORD( 2, 2 );  
    err = WSAStartup( wVersionRequested, &wsaData );  
    if ( err != 0 ) {  
        return;  
    }  
    if ( LOBYTE( wsaData.wVersion ) != 2 ||  
        HIBYTE( wsaData.wVersion ) != 2 ) {  
        WSACleanup( );  
        return;   
    }  
    SOCKET sockserver=socket(AF_INET,SOCK_DGRAM,0);  
    SOCKADDR_IN addrserver;  
    addrserver.sin_addr.S_un.S_addr=htonl(ADDR_ANY);  
    addrserver.sin_family=AF_INET;  
    addrserver.sin_port=htons(6000);  
    bind(sockserver,(SOCKADDR*)&addrserver,sizeof(SOCKADDR));  
    SOCKADDR_IN addrcient;  
    int len=sizeof(SOCKADDR);  
    char receiveBuf[100];  
    recvfrom(sockserver,receiveBuf,100,0,(SOCKADDR*)&addrcient,&len);  
    cout<<"来自客户端的消息:"<<receiveBuf<<endl;  
	sendto(sockserver,"hello123",strlen("hello123")+1,0,(SOCKADDR*)&addrcient,len);  
    closesocket(sockserver);  
    WSACleanup();  
}  