// SockClient.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdio.h>
#include <WINSOCK2.H>
int main(int argc, char* argv[])
{
WSADATA wd = { 0 };
WSAStartup(MAKEWORD(2,0),&wd);
SOCKET sock = socket(AF_INET , SOCK_STREAM ,0);
SOCKADDR_IN SvrAddr = { 0 };
SvrAddr.sin_family = AF_INET;
SvrAddr.sin_port = htons(5050);
SvrAddr.sin_addr.s_addr = inet_addr("192.168.1.111");
connect(sock,(sockaddr*)&SvrAddr , sizeof(sockaddr));
printf("Client: ");
char szBuf[255] = "";
scanf("%s" ,szBuf);
send(sock,szBuf,strlen(szBuf)+1 , 0);
recv(sock ,szBuf,255,0);
printf("service: %s\n" , szBuf);
closesocket(sock);
WSACleanup();
return 0;
}
Winsock网络编程客户端
最新推荐文章于 2024-06-20 21:45:01 发布