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

📄 tcpsocket.cpp

📁 agentspark 机器人模拟代码 适用robocup 机器人步态模拟仿真(机器人动作在NAOGETUP.cpp下修改)
💻 CPP
字号:
// -*-c++-*-

/***************************************************************************
                          tcpsocket.cpp  -  A simple tcp socket class
                             -------------------
    begin                : 08-JAN-2003
    copyright            : (C) 2003 by The RoboCup Soccer Server
                           Maintenance Group.
    email                : sserver-admin@lists.sourceforge.net
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU LGPL as published by the Free Software  *
 *   Foundation; either version 2 of the License, or (at your option) any  *
 *   later version.                                                        *
 *                                                                         *
 ***************************************************************************/

#include "tcpsocket.hpp"

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <sys/types.h>
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#include <cerrno>
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif

#ifdef HAVE_WINSOCK2_H
#include "Winsock2.h"
#endif

#include <iostream>

namespace rcss
{
    namespace net
    {
        TCPSocket::TCPSocket()
        {
            open();
        }

        TCPSocket::TCPSocket( SocketDesc& s )
            : Socket( s )
        {}

        TCPSocket::TCPSocket( const Addr& addr )
        {
            open();
            bind( addr );
        }

        TCPSocket::TCPSocket( const Addr& addr, const Addr& dest )
        {
            open();
                        bind( addr );
            connect( dest );
        }

        bool
        TCPSocket::doOpen( SocketDesc& fd )
        {
            close();
            fd = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP );
            return fd >= 0;
        }
    }
}

⌨️ 快捷键说明

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