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

📄 cuc.c

📁 稀疏矩阵、链表、图、队列、二叉树、多叉树、排序、遗传算法等的实现
💻 C
字号:
/*  cuc.c - CUPS UDP Client Code***  Copyright (C) 1999   Chad Dixon*                       Macmillan Computer Publishing**  This program is free software; you can redistribute it*  and/or modify it under the terms of the GNU General*  Public License as published by the Free Software*  Foundation; either version 2 of the License, or*  (at your option) any later version.**  This program is distributed in the hope that it will*  be useful, but WITHOUT ANY WARRANTY; without even the*  implied warranty of MERCHANTABILITY or FITNESS FOR A*  PARTICULAR PURPOSE.  See the GNU General Public License*  for more details.**  You should have received a copy of the GNU General*  Public License along with this program; if not, write*  to the Free Software Foundation, Inc., 675 Mass Ave,*  Cambridge, MA 02139, USA.**  Chad Dixon may be contacted at:
*     http://www.loopy.org
**/#include <stdio.h>#include <string.h>#include "cups.h"int main(int argc, char *argv[]){  CUPS_INFO CupsInfo = {0};    CONNECTION ClientConnection = {0};    char data[32]={0};    int nRet=0;	  if (argc != 3)    {    printf("usage: application celcius hostname\n");    return EXIT_FAILURE;    }    sprintf(data, "%s", argv[1]);     CUPSInit(&CupsInfo);  if(CUPSStartup(&CupsInfo) != 0)  {    printf("Initialisation failed.\n");    fgets(data, sizeof data, stdin);    return EXIT_FAILURE;  }  if (CUPSGetHostByName(&ClientConnection, argv[2]) != 0)  {   printf("Failure to resolve Hostname. %s\n", argv[2]);       return EXIT_FAILURE;   }  if(0 != CUPSInitUDPConnection(&ClientConnection, INADDR_ANY, 1092))    {   printf("Can't open a socket!\n");       return EXIT_FAILURE;    }    if (0 != CUPSSendTo(&ClientConnection, data, sizeof data))   {    printf("Error on sendto\n");     }	   memset(data, 0, sizeof data);   if (0 != CUPSRecvFrom(&ClientConnection, data, sizeof data))   {    printf("Error on recvfrom\n");     }   printf("%s Celcius = %s Fahrenheight\n",argv[1],  data);   CUPSShutdownClientConnection(&ClientConnection, 2);   CUPSCleanup(&CupsInfo);  return EXIT_SUCCESS;}

⌨️ 快捷键说明

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