summaryrefslogtreecommitdiff
path: root/protocols/ace/INet/FTP_Session.h
blob: 5a3e5264af7b11e3ddd02d07ccd5c8179e45bf39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// $Id$

/**
 * @file FTP_Session.h
 *
 * @author Martin Corino <mcorino@remedy.nl>
 */

#ifndef ACE_FTP_SESSION_H
#define ACE_FTP_SESSION_H

#include /**/ "ace/pre.h"

#include "ace/SString.h"
#include "ace/Countdown_Time.h"
#include "ace/SOCK_Connector.h"
#include "ace/INET_Addr.h"
#include "ace/INet/INet_Export.h"
#include "ace/INet/FTP_Request.h"
#include "ace/INet/FTP_Response.h"
#include "ace/INet/StreamHandler.h"
#include "ace/INet/Sock_IOStream.h"

ACE_BEGIN_VERSIONED_NAMESPACE_DECL

namespace ACE
  {
    namespace FTP
      {
        /**
        * @class ACE_FTP_Session
        *
        * @brief Encapsulates FTP session.
        *
        */
        template <ACE_SYNCH_DECL>
        class Session_T
          {
            public:
              typedef ACE::IOS::StreamHandler<ACE_SOCK_STREAM, ACE_SYNCH_USE> connection_type;

              enum
              {
                FTP_PORT = 21
              };

              Session_T ();

              Session_T (const ACE_Time_Value& timeout);

              virtual ~Session_T ();

              bool is_connected () const;

              bool is_new_connection () const;

              void set_host (const ACE_CString& host, u_short port);

              void set_host (const ACE_CString& host);

              void set_port (u_short port);

              const ACE_CString& get_host () const;

              u_short get_port () const;

              bool connect (bool use_reactor = false);

              bool connect (connection_type* connection);

              bool send_request (Request& request);

              bool receive_response (Response& response);

              bool send_interrupt ();

              void close ();

              bool supports_ftp_extensions () const;

              void set_ftp_extension_support (bool f);

              bool is_reactive () const;

              const ACE_Time_Value& timeout () const;

              void get_local_addr (ACE_INET_Addr& loc_addr) const;

            private:
              enum
              {
                DEFAULT_TIMEOUT = 30,           // sec

                INTERRUPT = 244   // Telnet IP signal
              };

              ACE_CString host_;
              u_short port_;

              typedef ACE::IOS::Sock_IOStreamBase<ACE_SYNCH_USE> sock_stream_type;

              bool reactive_;
              connection_type* connection_;
              sock_stream_type* sock_stream_;
              ACE_Time_Value ftp_timeout_;
              bool cannot_reconnect_;
              bool has_ftp_ext_; // RFC 2428 - IPv6 and NAT
              bool new_connect_;
          };

        typedef Session_T<ACE_NULL_SYNCH> Session;
      }
  }

ACE_END_VERSIONED_NAMESPACE_DECL

#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
#include "ace/INet/FTP_Session.cpp"
#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */

#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
#pragma implementation ("FTP_Session.cpp")
#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */

#include /**/ "ace/post.h"
#endif /* ACE_FTP_SESSION_H */