//For every ECLWatchVisible dropzones, read: dropZoneName, directory, and, if available, computer. //For every Servers/Server in ECLWatchVisible dropzones, read: directory, // server name, and hostname(or IP). Create dropzone("@name", "@directory", "@computer", // "@netAddress", "@linux", "@sourceNode") tree into pSoftware. void CFileSpraySoapBindingEx::appendDropZones(double clientVersion, IConstEnvironment* env, const char* dfuwuidSourcePartIP, IPropertyTree* softwareTree) { Owned<IConstDropZoneInfoIterator> dropZoneItr = env->getDropZoneIterator(); ForEach(*dropZoneItr) { IConstDropZoneInfo& dropZoneInfo = dropZoneItr->query(); if (!dropZoneInfo.isECLWatchVisible()) //This code is used by ECLWatch. So, skip the DZs not for ECLWatch. continue; SCMStringBuffer dropZoneName, directory, computerName; dropZoneInfo.getName(dropZoneName); dropZoneInfo.getDirectory(directory); if (!dropZoneName.length() || !directory.length()) continue; bool isLinux = getPathSepChar(directory.str()) == '/' ? true : false; Owned<IConstDropZoneServerInfoIterator> dropZoneServerItr = dropZoneInfo.getServers(); ForEach(*dropZoneServerItr) { IConstDropZoneServerInfo& dropZoneServer = dropZoneServerItr->query(); StringBuffer name, server, networkAddress; dropZoneServer.getName(name); dropZoneServer.getServer(server); if (name.isEmpty() || server.isEmpty()) continue; IPropertyTree* dropZone = softwareTree->addPropTree("DropZone", createPTree()); dropZone->setProp("@name", dropZoneName.str()); dropZone->setProp("@computer", name.str()); dropZone->setProp("@directory", directory.str()); if (isLinux) dropZone->setProp("@linux", "true"); IpAddress ipAddr; ipAddr.ipset(server.str()); ipAddr.getIpText(networkAddress); if (!ipAddr.isNull()) { dropZone->addProp("@netAddress", networkAddress); if (!isEmptyString(dfuwuidSourcePartIP)) { IpAddress ip(dfuwuidSourcePartIP); if (ip.ipequals(ipAddr)) dropZone->addProp("@sourceNode", "1"); } } } } }
bool TcpServer::listen(const IpAddress& address, uint16_t port) { if(address.isNull()) return false; int fd = socket(AF_INET, SOCK_STREAM, 0); struct sockaddr_in addr; bzero(&addr, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_port = htons(port); inet_pton(AF_INET, address.toString().c_str(), &addr.sin_addr); if(bind(fd, (struct sockaddr *)&addr, sizeof(addr)) == 0) { setServerAddress(address); setServerPort(port); setSocketDescriptor(fd); if(::listen(fd, SOMAXCONN) == 0) return true; } return false; }