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

📄 netif.h

📁 RoboCup 2D 仿真组冠军源代码之1998年冠军队——CMUnited98源代码
💻 H
字号:
/* -*- Mode: C -*- *//* netif.h * CMUnited98 (soccer client for Robocup98) * Peter Stone <pstone@cs.cmu.edu> * Computer Science Department * Carnegie Mellon University * Copyright (C) 1998 Peter Stone * * CMUnited-98 was created by Peter Stone, Manuela Veloso, and Patrick Riley * * You may copy and distribute this program freely as long as you retain this notice. * If you make any changes or have any comments we would appreciate a message. *//* * netif.C handles the udp socket communication with the server * Based on Noda's sampleclient *//* * Definitions for UDP c/s program. */#ifndef __netif_h#define __netif_h#include <stdio.h>#include <string.h>#include <unistd.h>#include <sys/types.h>#include <sys/socket.h>#include <sys/file.h>#include <netinet/in.h>#include <arpa/inet.h>#include <netdb.h>#include <fcntl.h>#include <errno.h>#include <signal.h>#include <sys/wait.h>#ifdef Linux//#include <linux/time.h>#endif#define DEFAULT_PORT_NUMBER	6000#define MAXMESG			2048#define MAXARG			200#ifdef MEMSET#define bzero(a, b) memset(a, 0, b)#endif#ifndef Linuxextern "C" void usleep(unsigned long);#endif#ifdef __cplusplusclass Socket { public:  int			socketfd  ;  struct sockaddr_in	serv_addr ;};#elsetypedef struct socket{    int			socketfd  ;    struct sockaddr_in	serv_addr ;}Socket ;#endifextern Socket init_connection(char* host, int port) ;extern int    send_message(char* buf, Socket *sock) ;extern int    receive_message(char *buf, Socket *sock) ;extern void   close_connection(Socket *sock) ;inline int wait_message(char *buf, Socket *sock) {  if (receive_message(buf, sock) == 1) {    while (receive_message(buf, sock) == 1);    return 1;  }   else for (int i = 0; i < 20; i++)  {    if (receive_message(buf, sock) == 1) return 1;    usleep(100000);  }  return 0;}#endif

⌨️ 快捷键说明

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