本文整理汇总了C++中setPort函数的典型用法代码示例。如果您正苦于以下问题:C++ setPort函数的具体用法?C++ setPort怎么用?C++ setPort使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setPort函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setPort
void PortSpace::Release(const Value_t port)
{
if(port < min_ || port > max_ || IsUsed(port) == false)
return;
setPort(port, false);
}
示例2: query
/// read preference table from sql
void preferences::readDB(){
if(QFile::exists(DBlocation.c_str())){
db2 = QSqlDatabase::addDatabase("QSQLITE");
db2.setDatabaseName(DBlocation.c_str());
if(db2.open()){
QSqlQuery query(db2);
query = QString("SELECT * FROM pref");
while (query.next()){
QString QVal1 = query.value(1).toString();
QString QVal2 = query.value(2).toString();
QString QVal3 = query.value(3).toString();
QString QVal4 = query.value(4).toString();
QString QVal5 = query.value(5).toString();
QString QVal6 = query.value(6).toString();
setUser(QVal1.toStdString());
setPass(QVal2.toStdString());
setServ(QVal3.toStdString());
setPort(QVal4.toStdString());
setTable(QVal5.toStdString());
setSQL(QVal6.toStdString());
}
}
db2.removeDatabase("QSQLITE");
}
}
示例3: UnavailablePortError
void PortSpace::Use(const Value_t port)
{
if(IsUsed(port))
throw UnavailablePortError(port, *this);
setPort(port, true);
}
示例4: mysql_init
// Parameter-Konstruktor
CDatabase_Connection::CDatabase_Connection(string user, string password, string DB, string Host, int Port)
{
try
{
mysql_init(&my);
LoadDefaults();
setUsername(user);
setPassword(password);
setDB(DB);
setHost(Host);
setPort(Port);
this->connected = false;
this->initialised = false;
}
catch(...)
{
cerr << "An unexpected error occured in function 'Default-Constructor'!" << endl;
}
}
示例5: fprintf
void CSensorUSBMotionNodeAccel::closePort()
{
if (getPort() > -1) {
fprintf(stdout, "Closing %s sensor port...\n", getTypeStr());
}
if (m_node) {
if (m_node->is_connected() && m_node->is_reading()) {
m_node->stop(); // if started & reading
}
m_node->close();
delete m_node;
m_node = NULL;
setPort();
setType();
if (getPort() > -1) {
fprintf(stdout, "Port closed!\n");
fflush(stdout);
}
}
// close MN dll
if (m_WinDLLHandle) {
#ifdef __USE_DLOPEN__
if (dlclose(m_WinDLLHandle)) {
fprintf(stderr, "%s: dlclose error %s\n", getTypeStr(), dlerror());
}
#else // probably Windows - free library
#ifdef _WIN32
::FreeLibrary(m_WinDLLHandle);
#endif
#endif
m_WinDLLHandle = NULL;
}
}
示例6: throw
void SocketAddress::set(const char* hostname, int family, uint16_t port)
throw (UnknownHostException)
{
int addrLen = 0;
MX_ASSERT(NULL != hostname);
if (AF_UNSPEC == family)
{
if (!getAddrInfo(hostname, AF_INET6, &data_, &addrLen) && !getAddrInfo(
hostname, AF_INET, &data_, &addrLen))
{
THROW2(UnknownHostException, std::string("Unknown hostname: [") + hostname + "]");
}
}
else
{
if (!getAddrInfo(hostname, family, &data_, &addrLen))
{
THROW2(UnknownHostException, std::string("Unknown hostname: [") + hostname + "]");
}
}
setPort(port);
}
示例7: str
bool IPEndPoint::parse(sal_in_z const char* addressAndPort)
{
std::string str(addressAndPort);
// Get position of colon
size_t pos = str.find(":");
if (pos != std::string::npos) {
std::string strIP = str.substr(0, pos);
if(!mAddress.parse(strIP.c_str()))
return false;
// Check existence of port number after colon
if (str.length() > pos+1) {
int port;
if(str2Int(str.substr(pos+1).c_str(), port))
setPort(uint16_t(port));
else
return false;
}
} else {
return mAddress.parse(addressAndPort);
}
return true;
}
示例8: setPort
int SimpleRedisClient::redis_conect(const char* Host,int Port, int TimeOut)
{
setPort(Port);
setHost(Host);
setTimeout(TimeOut);
return redis_conect();
}
示例9: QObject
ChatServer::ChatServer(qint16 port, QObject *parent) :
QObject(parent)
{
ConnectionList = new QList<ChatConnection*>();
setPort(port);
bActive = false;
}
示例10: guard
void TreadmillFB303::make_fb303(
std::shared_ptr<std::thread>& server_thread,
int server_port,
Scheduler& scheduler) {
{
folly::SharedMutex::WriteHolder guard(instance_mutex);
if (instance) {
LOG(FATAL) << "Global Treadmill FB303 instance was already set";
}
instance = std::make_shared<TreadmillFB303>(scheduler);
}
auto server = std::make_shared<apache::thrift::ThriftServer>();
LOG(INFO) << "FB303 running on port " << server_port;
server->setPort(server_port);
server->setInterface(getGlobalTreadmillFB303());
TLSConfig::applyDefaultsToThriftServer(*server);
server_thread.reset(
new std::thread([server]() { server->serve(); }),
[server](std::thread* t) {
server->stop();
t->join();
delete t;
});
}
示例11: ASensorEventQueue_disableSensor
void CSensorAndroidBuiltIn::closePort()
{
if (m_pSensor && m_pSensorEventQueue) {
ASensorEventQueue_disableSensor(m_pSensorEventQueue, m_pSensor);
}
if (m_pSensorManager && m_pSensorEventQueue) {
ASensorManager_destroyEventQueue(m_pSensorManager, m_pSensorEventQueue);
}
strcpy(m_strVendor, "");
strcpy(m_strSensor, "");
m_pSensorManager = NULL;
m_pSensor = NULL;
m_pSensorEventQueue = NULL;
m_pLooper = NULL;
m_fResolution = 0.0f;
m_minDelayMsec = 0;
memset(m_xyz, 0x00, sizeof(float) * 3);
memset(m_strSensor, 0x00, _MAX_PATH);
memset(m_strVendor, 0x00, _MAX_PATH);
setType();
setPort();
}
示例12: HTTPClientSession
HTTPSClientSession::HTTPSClientSession(const SecureStreamSocket& socket, Session::Ptr pSession):
HTTPClientSession(socket),
_pContext(socket.context()),
_pSession(pSession)
{
setPort(HTTPS_PORT);
}
示例13: getWrapper
bool EClientSocket::eConnect( const char *host, unsigned int port, int clientId, bool extraAuth)
{
if( m_fd == -2) {
getWrapper()->error( NO_VALID_ID, FAIL_CREATE_SOCK.code(), FAIL_CREATE_SOCK.msg());
return false;
}
// reset errno
errno = 0;
// already connected?
if( m_fd >= 0) {
errno = EISCONN;
getWrapper()->error( NO_VALID_ID, ALREADY_CONNECTED.code(), ALREADY_CONNECTED.msg());
return false;
}
// normalize host
m_hostNorm = (host && *host) ? host : "127.0.0.1";
// initialize host and port
setHost( m_hostNorm);
setPort( port);
// try to connect to specified host and port
ConnState resState = CS_DISCONNECTED;
return eConnectImpl( clientId, extraAuth, &resState);
}
示例14: htonl
void Ipv4SocketAddress::setAddress(std::string const& addr) {
if (addr.empty()) {
pImpl_->ipv4address.sin_addr.s_addr = htonl(INADDR_ANY);
} else {
struct addrinfo addrhints;
struct addrinfo *res;
int err;
memset(&addrhints, 0, sizeof(addrhints));
if ((err = getaddrinfo(addr.c_str(), NULL, &addrhints, &res)) != 0) {
std::cerr << "SocketAddress::setAddress(): Error in socket address translation for " << addr << ": " << gai_strerror(err) << std::endl;
} else {
if (res->ai_canonname)
std::cerr << "Canonical name of socket: " << res->ai_canonname << std::endl;
switch (res->ai_family) {
case AF_INET:
memcpy(&pImpl_->ipv4address, res->ai_addr, sizeof(pImpl_->ipv4address));
setPort(port()); // Fix port in sockaddr
break;
default:
std::cerr << "SocketAddress::setAddress(): Socket addresses other than ipv4 not supported!" << std::endl;
break;
}
freeaddrinfo(res);
}
}
}
示例15: LogRelFlow
STDMETHODIMP HostUSBDeviceFilterWrap::COMSETTER(Port)(IN_BSTR aPort)
{
LogRelFlow(("{%p} %s: enter aPort=%ls\n", this, "HostUSBDeviceFilter::setPort", aPort));
VirtualBoxBase::clearError();
HRESULT hrc;
try
{
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc()))
throw autoCaller.rc();
hrc = setPort(BSTRInConverter(aPort).str());
}
catch (HRESULT hrc2)
{
hrc = hrc2;
}
catch (...)
{
hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
}
LogRelFlow(("{%p} %s: leave hrc=%Rhrc\n", this, "HostUSBDeviceFilter::setPort", hrc));
return hrc;
}