⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 client.c

📁 tiny tcpip on 8051 可以利用在單片機 各種相關應用
💻 C
字号:
//  捞 橇肺弊伐篮 Linux 肚绰 Cygwin俊辑 哪颇老窍咯 角青茄促. //弊矾搁 8051苞 捞歹齿阑 烹秦辑 皋矫瘤甫 林绊 罐绰促.#include <sys/types.h>#include <sys/socket.h>#include <stdio.h>#include <netinet/in.h>#include <arpa/inet.h>#include <unistd.h>#define PORT	9999int main(){	int sockfd;	int len;	int i;	char ch;	struct sockaddr_in address; /*AF_INET 档皋牢俊辑 林家绰 sockaddr_in捞扼 阂府绰 备炼眉甫 */					/*荤侩窍咯 疙矫茄促. 捞巴篮 netinet/in.h 俊 沥狼茄促*/	int result;	int cmd;	char buf[1600];    	i = 0;		sockfd = socket( AF_INET, SOCK_STREAM, 0);/*家南阑 积急茄促.*/	address.sin_family = AF_INET;	address.sin_addr.s_addr = inet_addr( "202.30.20.172" );	address.sin_port = htons(PORT);    	len = sizeof(address);	result = connect( sockfd, (struct sockaddr *)&address, len);        	if ( result == -1) {		perror("oops: client1");		exit(1);	}	printf("Connection Established..\n");	while(1) {		i++;		//usleep(100000);		write(sockfd,"I'm CSL..!" ,80);		printf("\t send number : %d \r\n",i);		memset(buf, 0, 512);		len = read(sockfd, buf, 1600);		if (len > 0){	    	printf("%s\r\n",buf);		}      	}		close(sockfd);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -