head 1.4; access; symbols; locks; strict; comment @# @; 1.4 date 2002.09.07.01.50.40; author curt; state Exp; branches; next 1.3; 1.3 date 2002.08.31.19.01.57; author curt; state Exp; branches; next 1.2; 1.2 date 2002.08.31.18.54.04; author curt; state Exp; branches; next 1.1; 1.1 date 2002.02.15.17.22.01; author curt; state Exp; branches; next ; desc @@ 1.4 log @Updated doxygen docs. @ text @
Main Page Class Hierarchy Compound List File List Compound Members File Members

# sg_socket_udp.hxx

Go to the documentation of this file.

    00001
    00006 // Written by Curtis Olson, started November 2001.
    00007 //
    00008 // Copyright (C) 2001  Curtis L. Olson - curt@@flightgear.org
    00009 //
    00010 // This program is free software; you can redistribute it and/or
    00011 // modify it under the terms of the GNU General Public License as
    00012 // published by the Free Software Foundation; either version 2 of the
    00013 // License, or (at your option) any later version.
    00014 //
    00015 // This program is distributed in the hope that it will be useful, but
    00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
    00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00018 // General Public License for more details.
    00019 //
    00020 // You should have received a copy of the GNU General Public License
    00021 // along with this program; if not, write to the Free Software
    00022 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    00023 //
    00024 // $Id: sg_socket_udp.hxx,v 1.1 2001/11/12 04:47:59 curt Exp $
    00025
    00026
    00027 #ifndef _SG_SOCKET_UDP_HXX
    00028 #define _SG_SOCKET_UDP_HXX
    00029
    00030
    00031 #ifndef __cplusplus
    00032 # error This library requires C++
    00033 #endif
    00034
    00035 #include <plib/netSocket.h>
    00036
    00037 #include <simgear/compiler.h>
    00038
    00039 #include STL_STRING
    00040
    00041 #include <simgear/math/sg_types.hxx>
    00042 #include <simgear/io/iochannel.hxx>
    00043
    00044 SG_USING_STD(string);
    00045
    00049 class SGSocketUDP : public SGIOChannel {
    00050
    00051 private:
    00052
    00053     netSocket sock;
    00054
    00055     string hostname;
    00056     string port_str;
    00057
    00058     char save_buf[ 2 * SG_IO_MAX_MSG_SIZE ];
    00059     int save_len;
    00060
    00061     short unsigned int port;
    00062
    00063 public:
    00064
    00099     SGSocketUDP( const string& host, const string& port );
    00100
    00102     ~SGSocketUDP();
    00103
    00104     // If specified as a server (in direction for now) open the master
    00105     // listening socket.  If specified as a client (out direction),
    00106     // open a connection to a server.
    00107     bool open( const SGProtocolDir d );
    00108
    00109     // read data from socket
    00110     int read( char *buf, int length );
    00111
    00112     // read data from socket
    00113     int readline( char *buf, int length );
    00114
    00115     // write data to a socket
    00116     int write( const char *buf, const int length );
    00117
    00118     // write null terminated string to a socket
    00119     int writestring( const char *str );
    00120
    00121     // close file
    00122     bool close();
    00123
    00128     bool setBlocking( bool value );
    00129
    00131     inline string get_hostname() const { return hostname; }
    00132
    00134     inline string get_port_str() const { return port_str; }
    00135 };
    00136
    00137
    00138 #endif // _SG_SOCKET_UDP_HXX

@ 1.3 log @Oops, try again. @ text @d99 1 a99 1