MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SocketClient.hpp
1 /*
2  Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; version 2 of the License.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #ifndef SOCKET_CLIENT_HPP
19 #define SOCKET_CLIENT_HPP
20 
21 #include <NdbTCP.h>
23 
25 {
26  struct sockaddr_in m_servaddr;
27  unsigned int m_connect_timeout_millisec;
28  unsigned short m_port;
29  char *m_server_name;
30  SocketAuthenticator *m_auth;
31 public:
32  SocketClient(const char *server_name, unsigned short port, SocketAuthenticator *sa = 0);
33  ~SocketClient();
34  bool init();
35  void set_port(unsigned short port) {
36  m_port = port;
37  m_servaddr.sin_port = htons(m_port);
38  };
39  void set_connect_timeout(unsigned int timeout_millisec) {
40  m_connect_timeout_millisec = timeout_millisec;
41  }
42  unsigned short get_port() { return m_port; };
43  char *get_server_name() { return m_server_name; };
44  int bind(const char* toaddress, unsigned short toport);
45  NDB_SOCKET_TYPE connect(const char* toaddress = 0, unsigned short port = 0);
46  bool close();
47 
48  NDB_SOCKET_TYPE m_sockfd;
49 };
50 
51 #endif // SOCKET_ClIENT_HPP