亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? connection.cpp

?? RoboCup仿真組世界冠軍源代碼
?? CPP
字號:
/*Copyright (c) 2000-2003, Jelle Kok, University of AmsterdamAll rights reserved.Redistribution and use in source and binary forms, with or withoutmodification, are permitted provided that the following conditions are met:1. Redistributions of source code must retain the above copyright notice, thislist of conditions and the following disclaimer.2. Redistributions in binary form must reproduce the above copyright notice,this list of conditions and the following disclaimer in the documentationand/or other materials provided with the distribution.3. Neither the name of the University of Amsterdam nor the names of itscontributors may be used to endorse or promote products derived from thissoftware without specific prior written permission.THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THEIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AREDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLEFOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIALDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ORSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVERCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USEOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*//*! \file Connection.cpp<pre><b>File:</b>          Connection.cpp<b>Project:</b>       Robocup Soccer Simulation Team: UvA Trilearn<b>Authors:</b>       Jelle Kok<b>Created:</b>       23/11/2000<b>Last Revision:</b> $ID$<b>Contents:</b>      This file contains the class definitions for the               Connection class which sets up a connection with the               soccer server.<hr size=2><h2><b>Changes</b></h2><b>Date</b>             <b>Author</b>          <b>Comment</b>23/11/2000       Jelle Kok       Initial version created</pre>*/#include <errno.h>       // EWOULDBLOCK#include <string.h>      // strlen#include <sys/types.h>   // socket#ifndef WIN32  #include <unistd.h>      // close  #include <sys/socket.h>  // socket#endif#ifdef Solaris#include <sys/socket.h>  // AF_INET SOCK_DGRAM#endif#include "Connection.h"#include "Logger.h"      // LOG//#include<iostream>using namespace std;extern Logger Log; /*!< This is a reference to the Logger for writing info to*//*****************************************************************************//********************** CONNECTION *******************************************//*****************************************************************************//*! Default constructor. Only sets the maximum message size. */Connection::Connection( ){  m_iMaxMsgSize = 2048;}/*! Constructor makes a connection with the server using the connect method.    \param hostname string representation of host machine (string or IP number)    \param port port number for connection of the host machine    \param iMaxSize maximum message size that can be sent or received */Connection::Connection(const char *hostname, int port, int iMaxSize){  m_iMaxMsgSize = iMaxSize;  if(  connect( hostname, port ) )    Log.log( 1,"(Connection:connection) Socket connection made with %s:%d",                                                             hostname, port );  else    Log.log( 1,"(Connection:Connection) Could not create connection with %s:%d"                                                          , hostname, port );}/*! Deconstructor closes the connection with the server */Connection::~Connection(){  disconnect();}/*! This method sets up a connection with the server.    \param hostname string representation of host machine (string or IP number)    \param port port number for connection of the host machine    \return bool indicating whether connection was made */bool Connection::connect(const char *host, int port ){  struct hostent *host_ent;  struct in_addr *addr_ptr;  struct sockaddr_in  cli_addr ;  int    sockfd ;  m_sock.socketfd = -1 ;#ifndef WIN32  if( (host_ent = (struct hostent*)gethostbyname(host)) == NULL)  {    // if not a string, get information from IP adress.  #ifdef Solaris    if( inet_addr(host) == ((in_addr_t)-1) )  #else    if( inet_addr(host) == INADDR_NONE )  #endif    {      cerr << "(Connection::connect) Cannot find host " << host << endl;      return false ;    }  }  else   // get the necessary information from the hostname (string)  {    addr_ptr = (struct in_addr *) *host_ent->h_addr_list;    host = inet_ntoa(*addr_ptr);  }#else    // winsock initialization  WORD     wVersionRequested;  WSADATA  wsaData;  wVersionRequested = MAKEWORD( 2, 2 );  if ( WSAStartup( wVersionRequested, &wsaData ) != 0 )      return false;  if ( LOBYTE( wsaData.wVersion ) != 2 ||       HIBYTE( wsaData.wVersion ) != 2 ) {      WSACleanup();      return false;  }  if(inet_addr(host) == INADDR_NONE){    if((host_ent = (struct hostent *)gethostbyname(host)) == NULL) {        return false;    } else {        addr_ptr = (struct in_addr *) *host_ent->h_addr_list ;        host = inet_ntoa(*addr_ptr) ;    }  }#endif  //  Open UDP socket.  if( (sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)  {    cerr << "(Connection::connect) Cannot create socket " << host << endl;    return false ;  }  // insert the information of the client  cli_addr.sin_family      = AF_INET ;  cli_addr.sin_addr.s_addr = htonl(INADDR_ANY) ;  cli_addr.sin_port        = htons(0) ;  // bind the client to the server socket  if(bind(sockfd, (struct sockaddr *) &cli_addr, sizeof(cli_addr)) < 0)  {    cerr << "(Connection::connect) Cannot bind local address " << host << endl;    return false ;  }  //  Fill in the structure with the address of the server.  m_sock.socketfd = sockfd ;  m_sock.serv_addr.sin_family       = AF_INET ;  m_sock.serv_addr.sin_addr.s_addr  = inet_addr(host);  m_sock.serv_addr.sin_port         = htons(port) ;  return true;}/*! This method closes the current socket connection.  */void Connection::disconnect( void ){  if (isConnected() )  {#ifdef WIN32    closesocket( m_sock.socketfd );#else    close(m_sock.socketfd) ;#endif    m_sock.socketfd = -1; // This also 'sets' isConnected() to false  }}/*! This method determines whether the socket connection is connected.    \return bool indicating whether socket connection is available */bool Connection::isConnected(void) const{  return(m_sock.socketfd != -1);}/*! This method reads a message from the connection. When there is    no message available, it blocks till it receives a message.    \param msg string in which message is stored    \param maxsize maximum size of the message.    \return -1: error, 0: 0 bytes were read, 1 when read was succesfull */int Connection::receiveMessage( char *msg, int maxsize ){#ifdef WIN32  int       servlen;#elif Solaris  int       servlen;#else  socklen_t servlen ;#endif  int n;  struct sockaddr_in serv_addr ;  servlen = sizeof(serv_addr) ;  // receive message from server  n = recvfrom(m_sock.socketfd, msg, maxsize, 0,                              (struct sockaddr *)&serv_addr, &servlen);  if(n < 0)                                   // error  {#ifdef WIN32    if( n == -1 && errno == WSAEWOULDBLOCK)#else    if( n == -1 && errno == EWOULDBLOCK)#endif        {      msg[0] = '\0' ;      return 0 ;    }    else      return -1;  }  else                                       // succesfull, set new server info  {                                          // next message will go to there    m_sock.serv_addr.sin_port = serv_addr.sin_port ;    msg[n] = '\0' ;    return ( n == 0 ) ? 0 : 1 ;  }}/*! This method sends a message to the server using the current connection.    \param msg string which contains message    \return true on succes, false in case of failure */bool Connection::sendMessage( const char *msg ){  int n;  n = strlen(msg) + 1 ;  if( sendto(m_sock.socketfd, msg, n, 0,      (struct sockaddr *)&m_sock.serv_addr, sizeof(m_sock.serv_addr)) != n )    return false ;  return true ;}/*! This method always loops and waits for input. When input is received from    fpin then this input is send to the server using the current connection.    When message is received from the server, this message is sent to fpout.    \param fpin file pointer from which input is read (i.e. stdin )    \param fpout file pointer to which output should be directed (i.e. stdout)    \return 0 but only when error occured in reading input */#ifndef WIN32int Connection::message_loop( FILE *fpin, FILE *fpout ){  fd_set readfds, readfds_bak;  int in, max_fd, n, ret;  char buf[m_iMaxMsgSize];  in = fileno( fpin );  FD_ZERO( &readfds );  FD_SET( in, &readfds );  readfds_bak = readfds;  max_fd = ((in > m_sock.socketfd) ? in : m_sock.socketfd) = 1;  while( 1 )  {    readfds = readfds_bak;    // wait for message from socket or fpin    if(( ret = select( max_fd, &readfds, NULL, NULL, NULL )) < 0 )    {      perror("select");      break;    }    else if( ret != 0 )    {      if( FD_ISSET(in, &readfds))               // file descriptor fpin was set      {        fgets(buf, m_iMaxMsgSize, fpin);        // get the message        if( sendMessage(buf ) == false )        // and send it          break;      }      if( FD_ISSET(m_sock.socketfd, &readfds ) )// file descriptor was set      {        n = receiveMessage(buf, m_iMaxMsgSize); // receive the message        if( n == -1 )          break;        else if( n > 0 )                        // and put it to fpout        {          fputs(buf, fpout);          fputc( '\n', fpout);        }        fflush(stdout);      }    }  }  return 0;}#endif/*! This method prints whether the connection is up or not.    \param os output stream to which output should be directed */void Connection::show( ostream os ){  if( ! isConnected() )    os << "Not connected" << endl;  else    os << "Connected" << endl;}/********************** TESTING PURPOSES *************************************//*int main( void ){  char strBuf[m_iMaxMsgSize];  Connection c( "localhost", 6000 );  int i;  c.sendMessage( "(init l (version 6.07))" );  while( 1 )  {    i = c.receiveMessage( strBuf, m_iMaxMsgSize );    printf("%d|%s|\n", i, strBuf );  }  return 0;}*/

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩成人午夜精品| 欧美视频中文字幕| 蜜臀av性久久久久av蜜臀妖精 | 日本中文在线一区| 亚洲综合视频在线观看| 一区二区三区日韩在线观看| 亚洲精品菠萝久久久久久久| 亚洲精品国产a| 亚洲高清久久久| 日韩1区2区日韩1区2区| 亚洲三级理论片| 中文字幕综合网| 亚洲一区免费观看| 日韩av中文字幕一区二区三区| 天天色天天爱天天射综合| 麻豆国产91在线播放| 狠狠狠色丁香婷婷综合激情 | 日本成人在线不卡视频| 日本欧美在线观看| 国产精品18久久久久久久网站| 国产精品一区二区无线| 91视频一区二区三区| 欧美三级三级三级爽爽爽| 日本麻豆一区二区三区视频| 麻豆国产精品官网| 成人毛片老司机大片| 91久久精品日日躁夜夜躁欧美| 欧美人牲a欧美精品| 91精品福利在线一区二区三区| 日韩精品一区在线观看| 亚洲欧洲在线观看av| 天天操天天干天天综合网| 精品亚洲国产成人av制服丝袜| 成人av网站免费| 制服丝袜亚洲播放| 国产精品国产三级国产专播品爱网| 亚洲与欧洲av电影| 国产一区二区不卡| 欧美精品日日鲁夜夜添| 国产欧美日韩亚州综合| 日产精品久久久久久久性色| av在线不卡电影| 精品国产一区a| 国产91丝袜在线播放| 中文字幕精品一区二区精品绿巨人 | 综合色中文字幕| 日本免费在线视频不卡一不卡二 | 亚洲欧洲成人av每日更新| 爽好久久久欧美精品| 成人av在线资源网站| 7777精品伊人久久久大香线蕉最新版| 国产亚洲欧美色| 美女脱光内衣内裤视频久久网站| 99久久精品免费看国产免费软件| 日韩精品一区二区三区视频在线观看 | 国产精品福利影院| 5566中文字幕一区二区电影| 国产亚洲精品aa| 天堂久久久久va久久久久| 不卡的看片网站| 久久色视频免费观看| 日产国产欧美视频一区精品| 欧美综合一区二区| 最新久久zyz资源站| 成人免费毛片片v| 久久久www免费人成精品| 麻豆国产欧美日韩综合精品二区| 制服视频三区第一页精品| 依依成人精品视频| 日本高清不卡一区| 一区二区三区日韩欧美精品| 97久久精品人人爽人人爽蜜臀| 久久视频一区二区| 国产乱色国产精品免费视频| 精品国产露脸精彩对白| 九色综合狠狠综合久久| 久久久久久久久久看片| 国产乱人伦精品一区二区在线观看| 日韩欧美国产一区二区三区 | 国产视频一区在线观看 | 不卡一区二区三区四区| 久久久久国产精品人| 国产伦精品一区二区三区免费迷| 精品国产91乱码一区二区三区| 日韩国产精品久久久| 日韩欧美亚洲国产精品字幕久久久| 天堂影院一区二区| 日韩视频在线永久播放| 精品在线视频一区| 日本一区二区免费在线观看视频 | 欧美日本一区二区三区四区 | 日韩一区二区三区电影在线观看 | 国产成人精品免费在线| 中文一区二区完整视频在线观看| 成人免费va视频| 亚洲精品国产a| 欧美一区三区四区| 国产不卡高清在线观看视频| 亚洲视频香蕉人妖| 欧美一区二区免费观在线| 久久se这里有精品| 亚洲欧美综合另类在线卡通| 欧美私模裸体表演在线观看| 美腿丝袜亚洲一区| 国产精品日韩成人| 欧美精品成人一区二区三区四区| 国产专区综合网| 亚洲免费色视频| 日韩欧美国产wwwww| av男人天堂一区| 日日夜夜精品视频免费| 日韩毛片高清在线播放| 欧美肥大bbwbbw高潮| 国产成人高清在线| 日本午夜精品一区二区三区电影| 中文一区一区三区高中清不卡| 欧美三级乱人伦电影| 高清不卡一区二区| 欧美a级理论片| 亚洲色图一区二区三区| 久久婷婷色综合| 91 com成人网| 色猫猫国产区一区二在线视频| 毛片一区二区三区| 亚洲成人激情自拍| 中文字幕一区av| 久久久三级国产网站| 4438成人网| 欧美色爱综合网| 91丨porny丨国产入口| 国产高清不卡一区二区| 日韩av电影免费观看高清完整版| 亚洲美女淫视频| 中文字幕欧美国产| 久久一日本道色综合| 欧美巨大另类极品videosbest| av电影天堂一区二区在线 | 中文字幕欧美激情一区| 日韩一级黄色片| 欧美视频一二三区| 91激情在线视频| a亚洲天堂av| 成人黄色网址在线观看| 丁香桃色午夜亚洲一区二区三区| 日韩欧美的一区二区| 色综合天天综合在线视频| 国产精品一区免费视频| 久久精品99国产国产精| 日本成人在线视频网站| 三级久久三级久久| 亚洲6080在线| 午夜精品国产更新| 日韩不卡一二三区| 蜜桃一区二区三区四区| 美女视频网站久久| 激情综合亚洲精品| 国产成人高清在线| 成人aa视频在线观看| 91麻豆高清视频| 日本精品一区二区三区高清 | 欧美色男人天堂| 在线欧美日韩精品| 在线视频一区二区免费| 日本高清免费不卡视频| 欧美日韩国产电影| 欧美久久久久免费| 欧美大片一区二区| wwww国产精品欧美| 国产精品久久久久天堂| 日韩美女视频19| 亚洲国产欧美日韩另类综合| 午夜电影一区二区三区| 免费成人av在线| 成人h动漫精品| 欧美亚男人的天堂| 欧美电视剧免费全集观看| 国产人妖乱国产精品人妖| 亚洲欧美另类小说视频| 日本欧美一区二区三区乱码| 国产九色sp调教91| 91精品1区2区| 精品日韩成人av| 亚洲欧洲综合另类在线| 日韩电影免费一区| 成人免费av在线| 在线成人免费视频| 亚洲国产精品成人综合| 亚洲国产裸拍裸体视频在线观看乱了 | 九色综合狠狠综合久久| 91小视频在线观看| 日韩欧美一级特黄在线播放| 欧美激情一区二区三区不卡| 亚洲国产sm捆绑调教视频 | 色美美综合视频| 精品日韩在线一区| 亚洲一区二区三区三| 国产精品一区三区| 欧美伦理电影网| 17c精品麻豆一区二区免费| 美女网站色91|