分类: WINDOWS
2010-06-21 16:35:43
#include
#include
int main()
{
WORD wVersionRequested;
WSADATA wsaData;
int err;
wVersionRequested = MAKEWORD( 1, 1 );
err = WSAStartup( wVersionRequested, &wsaData );
if ( err != 0 ) {
return 1;
}
if ( LOBYTE( wsaData.wVersion ) != 1 ||
HIBYTE( wsaData.wVersion ) != 1 )
{
WSACleanup( );
return 1;
}
struct sockaddr_in sco_addr;
int len = sizeof(SOCKADDR);
char buffer[100] = {"welcome to http://wiliiwin.cublog.cn/"};
sco_addr.sin_addr.S_un.S_addr = inet_addr("127.0.0.1");
sco_addr.sin_family = AF_INET;
sco_addr.sin_port = htons(6000);
SOCKET scoke_client = socket(AF_INET,SOCK_STREAM,0);
while (1)
{
connect(scoke_client,(SOCKADDR*)&sco_addr,len);
send(scoke_client,buffer,100,0);
closesocket(scoke_client);
}
WSACleanup();
return 0;
}