| 151 | } |
| 152 | |
| 153 | Connection* Connection::CreateRemoteConnection(bool sharedFileSystem, char const* pIPaddress, int port, ErrorCode* pError) |
| 154 | { |
| 155 | RemoteConnection* pConnection = 0; |
| 156 | |
| 157 | #ifdef ENABLE_NAMED_PIPES |
| 158 | if (pIPaddress == 0) |
| 159 | { |
| 160 | |
| 161 | sock::ClientNamedPipe* pNamedPipe = new sock::ClientNamedPipe() ; |
| 162 | |
| 163 | std::stringstream name; |
| 164 | name << port; |
| 165 | |
| 166 | bool ok = pNamedPipe->ConnectToServer(name.str().c_str()) ; |
| 167 | |
| 168 | if (ok) |
| 169 | { |
| 170 | // Wrap the pipe inside a remote connection object |
| 171 | pConnection = new RemoteConnection(sharedFileSystem, pNamedPipe) ; |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | if (!pConnection) |
| 176 | #endif |
| 177 | { |
| 178 | sock::ClientSocket* pSocket = new sock::ClientSocket() ; |
| 179 | |
| 180 | bool ok = pSocket->ConnectToServer(pIPaddress, port) ; |
| 181 | |
| 182 | if (!ok) |
| 183 | { |
| 184 | // BADBAD: Can we get a more detailed error from pSocket? |
| 185 | if (pError) |
| 186 | { |
| 187 | *pError = Error::kConnectionFailed ; |
| 188 | } |
| 189 | delete pSocket ; |
| 190 | return NULL ; |
| 191 | } |
| 192 | |
| 193 | // Wrap the socket inside a remote connection object |
| 194 | pConnection = new RemoteConnection(sharedFileSystem, pSocket) ; |
| 195 | } |
| 196 | |
| 197 | return pConnection ; |
| 198 | } |
| 199 | |
| 200 | /************************************************************* |
| 201 | * @brief Create a new connection object wrapping a socket. |
nothing calls this directly
no test coverage detected