00001 #ifndef SOCKET_DATA_CLASS 00002 #define SOCKET_DATA_CLASS 00003 00004 /*****************************************************************************\ 00005 * * 00006 * Name : socket_data * 00007 * Author : Chris Koeritz * 00008 * * 00009 * Purpose: * 00010 * * 00011 * Tracks the partially transmitted data for transports based on a socket * 00012 * metaphor, where a socket is merely a numerical designation of the channel. * 00013 * Note: this is a heavy-weight header. don't include it in other headers. * 00014 * * 00015 ******************************************************************************* 00016 * Copyright (c) 1991-$now By Author. This program is free software; you can * 00017 * redistribute it and/or modify it under the terms of the GNU General Public * 00018 * License as published by the Free Software Foundation; either version 2 of * 00019 * the License or (at your option) any later version. This is online at: * 00020 * http://www.fsf.org/copyleft/gpl.html * 00021 * Please send any updates to: fred@gruntose.com * 00022 \*****************************************************************************/ 00023 00024 #include "sockets_dll.h" 00025 00026 #include <basis/byte_array.h> 00027 #include <basis/istring.h> 00028 #include <mechanisms/time_stamp.h> 00029 00030 class SOCKETS_CLASS_STYLE socket_data 00031 { 00032 public: 00033 int _socket; // the number of the socket we are managing here. 00034 byte_array _partially_sent; // accumulates bytes from partial sends. 00035 byte_array _partially_received; // accumulates bytes from partial receives. 00036 byte_array _receive_buffer; // temporary that's used for reading. 00037 bool _is_server; // true if this socket is for a server. 00038 int _registered_interests; 00039 // the events being watched for on this socket. the bitwise or'ed items 00040 // in this are from the socket_interests enum. 00041 bool _connection_pending; 00042 // true if a connect or accept is pending. the default is true since we 00043 // do not want to try probing the socket until it has been connected, for 00044 // sockets in connected mode. 00045 int _server_socket; // non-zero if socket was accepted on root server socket. 00046 bool _connected_mode; // true if this is a connected type of socket. 00047 time_stamp _last_conn_alert; 00048 // when the connection was last given a check for a connected state. 00049 00050 socket_data(int socket = 0, bool server = true, int server_socket = 0, 00051 bool connected_mode = true) 00052 : _socket(socket), _is_server(server), _registered_interests(0), 00053 _connection_pending(true), _server_socket(server_socket), 00054 _connected_mode(connected_mode) {} 00055 ~socket_data() {} 00056 00057 bool server() const { return _is_server; } 00058 bool client() const { return !_is_server; } 00059 00060 istring text_form() const; 00061 // returns a descriptive list of the data contained here. 00062 }; 00063 00064 #endif 00065
1.5.1