Browse Source

Jupiter::Socket:

* Renamed bindToPort() to bind()
* Renamed connectToHost() to connect()
* Adjusted classes as necessary
Updated some copyright years
Incremented JUPITER_VERISON for release.
release/0.19
JustinAJ 10 years ago
parent
commit
a5f0625753
  1. 2
      Jupiter/IRC_Client.cpp
  2. 2
      Jupiter/Jupiter.h
  3. 8
      Jupiter/SecureSocket.cpp
  4. 6
      Jupiter/SecureSocket.h
  5. 14
      Jupiter/Socket.cpp
  6. 8
      Jupiter/Socket.h
  7. 2
      Jupiter/TCPSocket.h
  8. 2
      Jupiter/UDPSocket.h
  9. BIN
      Release/Jupiter.lib

2
Jupiter/IRC_Client.cpp

@ -1269,7 +1269,7 @@ int Jupiter::IRC::Client::primaryHandler()
bool Jupiter::IRC::Client::connect() bool Jupiter::IRC::Client::connect()
{ {
const Jupiter::ReadableString &clientAddress = Jupiter::IRC::Client::readConfigValue(STRING_LITERAL_AS_REFERENCE("ClientAddress")); const Jupiter::ReadableString &clientAddress = Jupiter::IRC::Client::readConfigValue(STRING_LITERAL_AS_REFERENCE("ClientAddress"));
if (Jupiter::IRC::Client::data_->sock->connectToHost(Jupiter::IRC::Client::data_->serverHostname.c_str(), Jupiter::IRC::Client::data_->serverPort, clientAddress.size() == 0 ? nullptr : Jupiter::CStringS(clientAddress).c_str(), (unsigned short)Jupiter::IRC::Client::readConfigLong(STRING_LITERAL_AS_REFERENCE("ClientPort"))) == false) if (Jupiter::IRC::Client::data_->sock->connect(Jupiter::IRC::Client::data_->serverHostname.c_str(), Jupiter::IRC::Client::data_->serverPort, clientAddress.size() == 0 ? nullptr : Jupiter::CStringS(clientAddress).c_str(), (unsigned short)Jupiter::IRC::Client::readConfigLong(STRING_LITERAL_AS_REFERENCE("ClientPort"))) == false)
return false; return false;
Jupiter::IRC::Client::data_->sock->setBlocking(false); Jupiter::IRC::Client::data_->sock->setBlocking(false);

2
Jupiter/Jupiter.h

@ -35,7 +35,7 @@
#define JUPITER_API #define JUPITER_API
#endif // _WIN32 #endif // _WIN32
#define JUPITER_VERSION "Jupiter 0.14" /** Version of this program at compile time. */ #define JUPITER_VERSION "Jupiter 0.15" /** Version of this program at compile time. */
#if defined __cplusplus #if defined __cplusplus
extern "C" extern "C"

8
Jupiter/SecureSocket.cpp

@ -81,9 +81,9 @@ Jupiter::SecureSocket *Jupiter::SecureSocket::accept()
return nullptr; return nullptr;
} }
bool Jupiter::SecureSocket::bindToPort(const char *hostname, unsigned short iPort, bool andListen) bool Jupiter::SecureSocket::bind(const char *hostname, unsigned short iPort, bool andListen)
{ {
return Jupiter::Socket::bindToPort(hostname, iPort, andListen); return Jupiter::Socket::bind(hostname, iPort, andListen);
} }
void Jupiter::SecureSocket::closeSocket() void Jupiter::SecureSocket::closeSocket()
@ -165,9 +165,9 @@ void Jupiter::SecureSocket::setCertificate(const Jupiter::ReadableString &pem)
Jupiter::SecureSocket::setCertificate(pem, pem); Jupiter::SecureSocket::setCertificate(pem, pem);
} }
bool Jupiter::SecureSocket::connectToHost(const char *hostname, unsigned short iPort, const char *clientAddress, unsigned short clientPort) bool Jupiter::SecureSocket::connect(const char *hostname, unsigned short iPort, const char *clientAddress, unsigned short clientPort)
{ {
return Jupiter::Socket::connectToHost(hostname, iPort, clientAddress, clientPort) && this->initSSL(); return Jupiter::Socket::connect(hostname, iPort, clientAddress, clientPort) && this->initSSL();
} }
int Jupiter::SecureSocket::peek() int Jupiter::SecureSocket::peek()

6
Jupiter/SecureSocket.h

@ -1,5 +1,5 @@
/** /**
* Copyright (C) 2013-2014 Justin James. * Copyright (C) 2013-2015 Justin James.
* *
* This license must be preserved. * This license must be preserved.
* Any applications, libraries, or code which make any use of any * Any applications, libraries, or code which make any use of any
@ -96,7 +96,7 @@ namespace Jupiter
* @param Address for client to bind to. * @param Address for client to bind to.
* @return True on success, false otherwise. * @return True on success, false otherwise.
*/ */
virtual bool connectToHost(const char *hostname, unsigned short iPort, const char *clientAddress = nullptr, unsigned short clientPort = 0) override; virtual bool connect(const char *hostname, unsigned short iPort, const char *clientAddress = nullptr, unsigned short clientPort = 0) override;
/** /**
* @brief Interface to provide simple binding to ports. * @brief Interface to provide simple binding to ports.
@ -106,7 +106,7 @@ namespace Jupiter
* @param andListen True if listen() should be called, false otherwise. * @param andListen True if listen() should be called, false otherwise.
* @return True on success, false otherwise. * @return True on success, false otherwise.
*/ */
virtual bool bindToPort(const char *hostname, unsigned short iPort, bool andListen = true) override; virtual bool bind(const char *hostname, unsigned short iPort, bool andListen = true) override;
/** /**
* @brief Accepts an incoming connection for the port bound to. * @brief Accepts an incoming connection for the port bound to.

14
Jupiter/Socket.cpp

@ -148,17 +148,17 @@ int Jupiter::Socket::getProtocol() const
return Jupiter::Socket::data_->sockProto; return Jupiter::Socket::data_->sockProto;
} }
bool Jupiter::Socket::connectToHost(addrinfo *info) bool Jupiter::Socket::connect(addrinfo *info)
{ {
#if defined _WIN32 #if defined _WIN32
if (!socketInit && !Jupiter::Socket::init()) return false; if (!socketInit && !Jupiter::Socket::init()) return false;
#endif // _WIN32 #endif // _WIN32
Jupiter::Socket::data_->rawSock = socket(info->ai_family, Jupiter::Socket::data_->sockType, Jupiter::Socket::data_->sockProto); Jupiter::Socket::data_->rawSock = socket(info->ai_family, Jupiter::Socket::data_->sockType, Jupiter::Socket::data_->sockProto);
if (Jupiter::Socket::data_->rawSock == INVALID_SOCKET || (Jupiter::Socket::data_->sockType != SOCK_RAW && Jupiter::Socket::data_->sockProto != IPPROTO_RAW && connect(Jupiter::Socket::data_->rawSock, info->ai_addr, info->ai_addrlen) == SOCKET_ERROR)) return false; if (Jupiter::Socket::data_->rawSock == INVALID_SOCKET || (Jupiter::Socket::data_->sockType != SOCK_RAW && Jupiter::Socket::data_->sockProto != IPPROTO_RAW && ::connect(Jupiter::Socket::data_->rawSock, info->ai_addr, info->ai_addrlen) == SOCKET_ERROR)) return false;
return true; return true;
} }
bool Jupiter::Socket::connectToHost(const char *hostname, unsigned short iPort, const char *clientAddress, unsigned short clientPort) bool Jupiter::Socket::connect(const char *hostname, unsigned short iPort, const char *clientAddress, unsigned short clientPort)
{ {
#if defined _WIN32 #if defined _WIN32
if (!socketInit && !Jupiter::Socket::init()) return false; if (!socketInit && !Jupiter::Socket::init()) return false;
@ -180,8 +180,8 @@ bool Jupiter::Socket::connectToHost(const char *hostname, unsigned short iPort,
sockaddr *asock = ainfo->ai_addr; sockaddr *asock = ainfo->ai_addr;
Jupiter::Socket::data_->rawSock = socket(ainfo->ai_family, Jupiter::Socket::data_->sockType, Jupiter::Socket::data_->sockProto); Jupiter::Socket::data_->rawSock = socket(ainfo->ai_family, Jupiter::Socket::data_->sockType, Jupiter::Socket::data_->sockProto);
if (Jupiter::Socket::data_->rawSock == INVALID_SOCKET) continue; if (Jupiter::Socket::data_->rawSock == INVALID_SOCKET) continue;
if (clientAddress != nullptr) this->bindToPort(clientAddress, clientPort, false); if (clientAddress != nullptr) this->bind(clientAddress, clientPort, false);
if (connect(Jupiter::Socket::data_->rawSock, asock, ainfo->ai_addrlen) == SOCKET_ERROR) if (::connect(Jupiter::Socket::data_->rawSock, asock, ainfo->ai_addrlen) == SOCKET_ERROR)
{ {
i++; i++;
continue; continue;
@ -192,7 +192,7 @@ bool Jupiter::Socket::connectToHost(const char *hostname, unsigned short iPort,
return false; return false;
} }
bool Jupiter::Socket::bindToPort(const char *hostname, unsigned short iPort, bool andListen) bool Jupiter::Socket::bind(const char *hostname, unsigned short iPort, bool andListen)
{ {
#if defined _WIN32 #if defined _WIN32
if (!socketInit && !Jupiter::Socket::init()) return false; if (!socketInit && !Jupiter::Socket::init()) return false;
@ -212,7 +212,7 @@ bool Jupiter::Socket::bindToPort(const char *hostname, unsigned short iPort, boo
return false; return false;
} }
Jupiter::Socket::data_->rawSock = socket(ainfo->ai_family, Jupiter::Socket::data_->sockType, Jupiter::Socket::data_->sockProto); Jupiter::Socket::data_->rawSock = socket(ainfo->ai_family, Jupiter::Socket::data_->sockType, Jupiter::Socket::data_->sockProto);
if (Jupiter::Socket::data_->rawSock == INVALID_SOCKET || bind(Jupiter::Socket::data_->rawSock, ainfo->ai_addr, ainfo->ai_addrlen) == SOCKET_ERROR) if (Jupiter::Socket::data_->rawSock == INVALID_SOCKET || ::bind(Jupiter::Socket::data_->rawSock, ainfo->ai_addr, ainfo->ai_addrlen) == SOCKET_ERROR)
{ {
i++; i++;
continue; continue;

8
Jupiter/Socket.h

@ -1,5 +1,5 @@
/** /**
* Copyright (C) 2013-2014 Justin James. * Copyright (C) 2013-2015 Justin James.
* *
* This license must be preserved. * This license must be preserved.
* Any applications, libraries, or code which make any use of any * Any applications, libraries, or code which make any use of any
@ -215,7 +215,7 @@ namespace Jupiter
* @param info addrinfo containing the information required to initialize the socket and attempt a connection. * @param info addrinfo containing the information required to initialize the socket and attempt a connection.
* @return True on success, false otherwise. * @return True on success, false otherwise.
*/ */
virtual bool connectToHost(addrinfo *info); virtual bool connect(addrinfo *info);
/** /**
* @brief Interface to provide simple connection establishing. * @brief Interface to provide simple connection establishing.
@ -226,7 +226,7 @@ namespace Jupiter
* @param clientPort Optional parameter to specify the port for socket to bind to. * @param clientPort Optional parameter to specify the port for socket to bind to.
* @return True on success, false otherwise. * @return True on success, false otherwise.
*/ */
virtual bool connectToHost(const char *hostname, unsigned short iPort, const char *clientHostname = nullptr, unsigned short clientPort = 0); virtual bool connect(const char *hostname, unsigned short iPort, const char *clientHostname = nullptr, unsigned short clientPort = 0);
/** /**
* @brief Interface to provide simple binding to ports. * @brief Interface to provide simple binding to ports.
@ -236,7 +236,7 @@ namespace Jupiter
* @param andListen True if listen() should be called, false otherwise. * @param andListen True if listen() should be called, false otherwise.
* @return True on success, false otherwise. * @return True on success, false otherwise.
*/ */
virtual bool bindToPort(const char *hostname, unsigned short iPort, bool andListen = true); virtual bool bind(const char *hostname, unsigned short iPort, bool andListen = true);
/** /**
* @brief Accepts an incoming connection for the port bound to. * @brief Accepts an incoming connection for the port bound to.

2
Jupiter/TCPSocket.h

@ -1,5 +1,5 @@
/** /**
* Copyright (C) 2013-2014 Justin James. * Copyright (C) 2013-2015 Justin James.
* *
* This license must be preserved. * This license must be preserved.
* Any applications, libraries, or code which make any use of any * Any applications, libraries, or code which make any use of any

2
Jupiter/UDPSocket.h

@ -1,5 +1,5 @@
/** /**
* Copyright (C) 2013-2014 Justin James. * Copyright (C) 2013-2015 Justin James.
* *
* This license must be preserved. * This license must be preserved.
* Any applications, libraries, or code which make any use of any * Any applications, libraries, or code which make any use of any

BIN
Release/Jupiter.lib

Binary file not shown.
Loading…
Cancel
Save