#include <SocketClient.hpp>
Collaboration diagram for SocketClient:

Public Member Functions | |
| SocketClient (const char *server_name, unsigned short port, SocketAuthenticator *sa=0) | |
| ~SocketClient () | |
| bool | init () |
| void | set_port (unsigned short port) |
| unsigned short | get_port () |
| char * | get_server_name () |
| NDB_SOCKET_TYPE | connect () |
| bool | close () |
Private Attributes | |
| NDB_SOCKET_TYPE | m_sockfd |
| sockaddr_in | m_servaddr |
| unsigned short | m_port |
| char * | m_server_name |
| SocketAuthenticator * | m_auth |
Definition at line 23 of file SocketClient.hpp.
| SocketClient::SocketClient | ( | const char * | server_name, | |
| unsigned short | port, | |||
| SocketAuthenticator * | sa = 0 | |||
| ) |
Definition at line 24 of file SocketClient.cpp.
References m_auth, m_port, m_server_name, m_sockfd, NDB_INVALID_SOCKET, and strdup().
00025 { 00026 m_auth= sa; 00027 m_port= port; 00028 m_server_name= strdup(server_name); 00029 m_sockfd= NDB_INVALID_SOCKET; 00030 }
Here is the call graph for this function:

| SocketClient::~SocketClient | ( | ) |
Definition at line 32 of file SocketClient.cpp.
References free, m_auth, m_server_name, m_sockfd, NDB_CLOSE_SOCKET(), and NDB_INVALID_SOCKET.
00033 { 00034 if (m_server_name) 00035 free(m_server_name); 00036 if (m_sockfd != NDB_INVALID_SOCKET) 00037 NDB_CLOSE_SOCKET(m_sockfd); 00038 if (m_auth) 00039 delete m_auth; 00040 }
Here is the call graph for this function:

| bool SocketClient::close | ( | ) |
| NDB_SOCKET_TYPE SocketClient::connect | ( | ) |
Definition at line 66 of file SocketClient.cpp.
References SocketAuthenticator::client_authenticate(), init(), m_auth, m_port, m_servaddr, m_server_name, m_sockfd, NDB_CLOSE_SOCKET(), NDB_INVALID_SOCKET, NDB_SOCKET_TYPE, and ndbout().
Referenced by Transporter::connect_client(), and ndb_mgm_listen_event_internal().
00067 { 00068 if (m_sockfd == NDB_INVALID_SOCKET) 00069 { 00070 if (!init()) { 00071 #ifdef VM_TRACE 00072 ndbout << "SocketClient::connect() failed " << m_server_name << " " << m_port << endl; 00073 #endif 00074 return NDB_INVALID_SOCKET; 00075 } 00076 } 00077 const int r = ::connect(m_sockfd, (struct sockaddr*) &m_servaddr, sizeof(m_servaddr)); 00078 if (r == -1) { 00079 NDB_CLOSE_SOCKET(m_sockfd); 00080 m_sockfd= NDB_INVALID_SOCKET; 00081 return NDB_INVALID_SOCKET; 00082 } 00083 00084 if (m_auth) { 00085 if (!m_auth->client_authenticate(m_sockfd)) 00086 { 00087 NDB_CLOSE_SOCKET(m_sockfd); 00088 m_sockfd= NDB_INVALID_SOCKET; 00089 return NDB_INVALID_SOCKET; 00090 } 00091 } 00092 NDB_SOCKET_TYPE sockfd= m_sockfd; 00093 m_sockfd= NDB_INVALID_SOCKET; 00094 00095 return sockfd; 00096 }
Here is the call graph for this function:

Here is the caller graph for this function:

| unsigned short SocketClient::get_port | ( | ) | [inline] |
Definition at line 38 of file SocketClient.hpp.
References m_port.
Referenced by TransporterRegistry::connect_ndb_mgmd().
00038 { return m_port; };
Here is the caller graph for this function:

| char* SocketClient::get_server_name | ( | ) | [inline] |
Definition at line 39 of file SocketClient.hpp.
References m_server_name.
Referenced by TransporterRegistry::connect_ndb_mgmd().
00039 { return m_server_name; };
Here is the caller graph for this function:

| bool SocketClient::init | ( | ) |
Definition at line 43 of file SocketClient.cpp.
References DBUG_PRINT, m_port, m_servaddr, m_server_name, m_sockfd, memset, NDB_CLOSE_SOCKET(), Ndb_getInAddr(), and NDB_INVALID_SOCKET.
Referenced by connect().
00044 { 00045 if (m_sockfd != NDB_INVALID_SOCKET) 00046 NDB_CLOSE_SOCKET(m_sockfd); 00047 00048 memset(&m_servaddr, 0, sizeof(m_servaddr)); 00049 m_servaddr.sin_family = AF_INET; 00050 m_servaddr.sin_port = htons(m_port); 00051 // Convert ip address presentation format to numeric format 00052 if (Ndb_getInAddr(&m_servaddr.sin_addr, m_server_name)) 00053 return false; 00054 00055 m_sockfd= socket(AF_INET, SOCK_STREAM, 0); 00056 if (m_sockfd == NDB_INVALID_SOCKET) { 00057 return false; 00058 } 00059 00060 DBUG_PRINT("info",("NDB_SOCKET: %d", m_sockfd)); 00061 00062 return true; 00063 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void SocketClient::set_port | ( | unsigned short | port | ) | [inline] |
Definition at line 34 of file SocketClient.hpp.
References m_port.
Referenced by Transporter::set_s_port().
00034 { 00035 m_port = port; 00036 m_servaddr.sin_port = htons(m_port); 00037 };
Here is the caller graph for this function:

SocketAuthenticator* SocketClient::m_auth [private] |
Definition at line 29 of file SocketClient.hpp.
Referenced by connect(), SocketClient(), and ~SocketClient().
unsigned short SocketClient::m_port [private] |
Definition at line 27 of file SocketClient.hpp.
Referenced by connect(), get_port(), init(), set_port(), and SocketClient().
struct sockaddr_in SocketClient::m_servaddr [private] |
char* SocketClient::m_server_name [private] |
Definition at line 28 of file SocketClient.hpp.
Referenced by connect(), get_server_name(), init(), SocketClient(), and ~SocketClient().
NDB_SOCKET_TYPE SocketClient::m_sockfd [private] |
Definition at line 25 of file SocketClient.hpp.
Referenced by connect(), init(), SocketClient(), and ~SocketClient().
1.4.7

