本文整理汇总了C++中sf::TcpSocket::connect方法的典型用法代码示例。如果您正苦于以下问题:C++ TcpSocket::connect方法的具体用法?C++ TcpSocket::connect怎么用?C++ TcpSocket::connect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sf::TcpSocket
的用法示例。
在下文中一共展示了TcpSocket::connect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doSwitchMode
void doSwitchMode(Mode mode){
arduino.connect(ip, port);
if (mode != currentMode){
currentMode = mode;
char data;
switch (mode){
case Mode::SolidWhite: data = (char) 0;
break;
case Mode::Marquee: data = (char) 1;
break;
case Mode::ColorCycle: data = (char) 2;
break;
case Mode::Pew: data = (char) 3;
break;
default: break;
}
char* dataPointer = &data;
arduino.send(dataPointer, sizeof(data));
}
arduino.disconnect();
}
示例2: connect
inline bool connect(sf::IpAddress mIp, unsigned short mPort)
{
if(busy) { ssvu::lo("ManagedSocket") << "Error: already connected" << std::endl; return false; }
for(int i{0}; i < 5; ++i)
{
if(!busy && socket.connect(mIp, mPort) == sf::Socket::Done) goto succeed;
std::this_thread::sleep_for(std::chrono::milliseconds(50));
}
return false;
succeed:
if(!busy)
{
ssvu::lo("ManagedSocket") << "Connecting..." << std::endl;
busy = true;
handlerFuture = std::async(std::launch::async, [this]{ while(busy) update(); });
}
ssvu::lo("ManagedSocket") << "Connected to " << mIp.toString() << ":" << mPort << std::endl;
return true;
}