本文整理汇总了C++中IpAddress::set方法的典型用法代码示例。如果您正苦于以下问题:C++ IpAddress::set方法的具体用法?C++ IpAddress::set怎么用?C++ IpAddress::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IpAddress
的用法示例。
在下文中一共展示了IpAddress::set方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[])
{
InitModuleObjects();
EnableSEHtoExceptionMapping();
if (argc<6)
{
usage();
return 0;
}
try
{
const char *filename = argv[1];
Owned<IDaliCapabilityCreator> cc = createDaliCapabilityCreator();
cc->setSystemID(argv[2]);
cc->setServerPassword(argv[3]);
for (unsigned i=4;i<argc;i++) {
const char *cmd = argv[i++];
if (i==argc)
break;
const char *param = argv[i];
if (stricmp(cmd,"THORWIDTH")==0) {
cc->setLimit(DCR_ThorSlave,atoi(param));
}
else if (stricmp(cmd,"DALINODE")==0) {
StringBuffer mac;
if (strchr(param,'.')) { // must be ip
IpAddress ip;
ip.set(param);
if (!getMAC(ip,mac)) {
printf("ERROR: could mot get MAC address for %s\n",param);
return 1;
}
}
else
mac.append(param);
cc->addCapability(DCR_DaliServer,mac.str());
}
else {
printf("ERROR: unknown command %s\n",cmd);
return 1;
}
}
StringBuffer results;
cc->save(results);
Owned<IFile> ifile = createIFile(filename);
Owned<IFileIO> ifileio = ifile->open(IFOcreate);
ifileio->write(0,results.length(),results.str());
printf("Dali Capabilities sucessfully exported to %s\n", filename);
}
catch (IException *e)
{
EXCLOG(e);
e->Release();
}
releaseAtoms();
return 0;
}
示例2: accept
Status TcpSocket::accept(socket_details::socket_t &peer, IpAddress &remoteAddress) {
socket_details::sockaddr_t addr;
unsigned int addrLen = sizeof(addr);
peer = ::accept(mHandle, reinterpret_cast<sockaddr*>(&addr), &addrLen);
if(peer < 0) {
return getLastError();
}
remoteAddress.set(addr);
return net::Ok;
}
示例3: recv
net::Status UdpSocket::recv(void *data, size_t buffer_size, size_t &received, IpAddress &from) {
if (data == NULL) {
received = 0;
return Error;
}
socket_details::sockaddr_t addr = socket_details::create_address(0, 0);
unsigned int addr_len = sizeof(addr);
ssize_t ret = ::recvfrom(handle(), static_cast<char *>(data), buffer_size, 0,
reinterpret_cast<::sockaddr *>(&addr), &addr_len);
if (ret < 0) {
return getLastError();
received = 0;
} else {
received = static_cast<size_t>(ret);
from.set(addr);
}
return Ok;
}