本文整理汇总了C++中SocketEndpoint::set方法的典型用法代码示例。如果您正苦于以下问题:C++ SocketEndpoint::set方法的具体用法?C++ SocketEndpoint::set怎么用?C++ SocketEndpoint::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SocketEndpoint
的用法示例。
在下文中一共展示了SocketEndpoint::set方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateDaliEnv
bool updateDaliEnv(IPropertyTree *env, bool forceGroupUpdate, const char *daliIp)
{
Owned<IPropertyTreeIterator> dalis = env->getElements("Software/DaliServerProcess/Instance");
if (!dalis||!dalis->first()) {
fprintf(stderr,"Could not find DaliServerProcess\n");
return false;
}
SocketEndpoint daliep;
loop {
const char *ps = dalis->get().queryProp("@port");
unsigned port = ps?atoi(ps):0;
if (!port)
port = DALI_SERVER_PORT;
daliep.set(dalis->get().queryProp("@netAddress"),port);
if (daliIp && *daliIp) {
SocketEndpoint testep;
testep.set(daliIp,DALI_SERVER_PORT);
if (testep.equals(daliep))
break;
daliep.set(NULL,0);
}
if (!dalis->next())
break;
if (!daliep.isNull()) {
fprintf(stderr,"Ambiguous DaliServerProcess instance\n");
return false;
}
}
if (daliep.isNull()) {
fprintf(stderr,"Could not find DaliServerProcess instance\n");
return false;
}
SocketEndpointArray epa;
epa.append(daliep);
Owned<IGroup> group = createIGroup(epa);
bool ret = true;
initClientProcess(group, DCR_Util);
StringBuffer response;
if (querySDS().updateEnvironment(env, forceGroupUpdate, response))
{
StringBuffer tmp;
PROGLOG("Environment and node groups updated in dali at %s",daliep.getUrlStr(tmp).str());
}
else
ret = false;
if (response.length())
WARNLOG("%s", response.str());
closedownClientProcess();
return ret;
}
示例2: checkLocalDaFileSvr
bool CDfuPlusHelper::checkLocalDaFileSvr(const char *eps,SocketEndpoint &epout)
{
if (!eps||!*eps)
epout.setLocalHost(DAFILESRV_PORT);
else {
epout.set(eps,DAFILESRV_PORT);
if (!epout.isLocal())
return false;
}
progress("Checking for local Dali File Server\n");
if (!testDaliServixPresent(epout)) // only lookup local
runLocalDaFileSvr(epout,false,0);
return true;
}
示例3: main
int main(int argc, char* argv[])
{
InitModuleObjects();
int exitCode = 1;
try
{
if (argc<2)
{
printf("usage: dalistop <server_ip:port> [/nowait]\n");
printf("eg: dalistop . -- stop dali server running locally\n");
printf(" dalistop eq0001016 -- stop dali server running remotely\n");
}
else
{
SocketEndpoint ep;
ep.set(argv[1],DALI_SERVER_PORT);
bool nowait = false;
if (argc>=3)
nowait = stricmp(argv[2],"/nowait")==0;
printf("Stopping Dali Server on %s\n",argv[1]);
startMPServer(0);
Owned<IGroup> group = createIGroup(1,&ep);
Owned<ICommunicator> comm = createCommunicator(group);
CMessageBuffer mb;
int fn=-1;
mb.append(fn);
if (comm->verifyConnection(0,2000))
{
comm->send(mb,0,MPTAG_DALI_COVEN_REQUEST,MP_ASYNC_SEND);
if (nowait)
{
Sleep(1000);
exitCode = 0;
}
else
{
// verifyConnection() has a min conn timeout of 10s
// use recv() instead to check for socket closed ...
try
{
while (!comm->recv(mb,0,MPTAG_DALI_COVEN_REQUEST,nullptr,5000))
{
printf("Waiting for Dali Server to stop....\n");
}
exitCode = 0;
}
catch (IMP_Exception *e)
{
if (e->errorCode() == MPERR_link_closed)
exitCode = 0;
e->Release();
}
}
}
else
fprintf(stderr, "Dali not responding\n");
stopMPServer();
}
}
catch (IException *e)
{
pexception("Exception",e);
stopMPServer();
}
releaseAtoms();
return exitCode;
}
示例4: main
int main( int argc, char *argv[] )
{
#if defined(WIN32) && defined(_DEBUG)
int tmpFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG );
tmpFlag |= _CRTDBG_LEAK_CHECK_DF;
_CrtSetDbgFlag( tmpFlag );
#endif
InitModuleObjects();
addAbortHandler(ControlHandler);
EnableSEHtoExceptionMapping();
dummyProc();
#ifndef __64BIT__
// Restrict stack sizes on 32-bit systems
Thread::setDefaultStackSize(0x10000); // NB under windows requires linker setting (/stack:)
#endif
#ifdef _WIN32
Owned<CReleaseMutex> globalNamedMutex;
#endif
if (globals)
globals->Release();
{
Owned<IFile> iFile = createIFile("thor.xml");
globals = iFile->exists() ? createPTree(*iFile, ipt_caseInsensitive) : createPTree("Thor", ipt_caseInsensitive);
}
unsigned multiThorMemoryThreshold = 0;
Owned<IException> unregisterException;
try
{
if (argc==1)
{
usage();
return 1;
}
cmdArgs = argv+1;
mergeCmdParams(globals);
cmdArgs = argv+1;
const char *master = globals->queryProp("@MASTER");
if (!master)
usage();
const char *slave = globals->queryProp("@SLAVE");
if (slave)
{
slfEp.set(slave);
localHostToNIC(slfEp);
}
else
slfEp.setLocalHost(0);
mySlaveNum = globals->getPropInt("@SLAVENUM");
setMachinePortBase(slfEp.port);
slfEp.port = getMachinePortBase();
startSlaveLog();
setSlaveAffinity(globals->getPropInt("@SLAVEPROCESSNUM"));
startMPServer(getFixedPort(TPORT_mp));
#ifdef USE_MP_LOG
startLogMsgParentReceiver();
LOG(MCdebugProgress, thorJob, "MPServer started on port %d", getFixedPort(TPORT_mp));
#endif
SocketEndpoint masterEp(master);
localHostToNIC(masterEp);
setMasterPortBase(masterEp.port);
markNodeCentral(masterEp);
if (RegisterSelf(masterEp))
{
if (globals->getPropBool("Debug/@slaveDaliClient"))
enableThorSlaveAsDaliClient();
IDaFileSrvHook *daFileSrvHook = queryDaFileSrvHook();
if (daFileSrvHook) // probably always installed
daFileSrvHook->addFilters(globals->queryPropTree("NAS"), &slfEp);
StringBuffer thorPath;
globals->getProp("@thorPath", thorPath);
recursiveCreateDirectory(thorPath.str());
int err = _chdir(thorPath.str());
if (err)
{
IException *e = makeErrnoExceptionV(-1, "Failed to change dir to '%s'", thorPath.str());
FLLOG(MCexception(e), thorJob, e);
throw e;
}
// Initialization from globals
setIORetryCount(globals->getPropInt("Debug/@ioRetries")); // default == 0 == off
StringBuffer str;
if (globals->getProp("@externalProgDir", str.clear()))
//.........这里部分代码省略.........
示例5: start
int COneServerHttpProxyThread::start()
{
try
{
char peername[256];
int port = m_client->peer_name(peername, 256);
if(httptest_tracelevel > 5)
fprintf(m_ofile, "\n>>receivd request from %s:%d\n", peername, port);
StringBuffer requestbuf;
Owned<IByteOutputStream> reqstream = createOutputStream(requestbuf);
receiveData(m_client, reqstream.get(), false);
if(httptest_tracelevel > 10)
fprintf(m_ofile, "%s%s%s", sepstr, requestbuf.str(), sepstr);
SocketEndpoint ep;
Owned<ISocket> socket2;
ep.set(m_host.str(), m_port);
socket2.setown(ISocket::connect(ep));
if(m_use_ssl && m_ssctx != NULL)
{
Owned<ISecureSocket> securesocket = m_ssctx->createSecureSocket(socket2.getLink());
int res = securesocket->secure_connect();
if(res >= 0)
{
socket2.set(securesocket.get());
}
}
if(socket2.get() == NULL)
{
StringBuffer urlstr;
DBGLOG(">>Can't connect to %s", ep.getUrlStr(urlstr).str());
return -1;
}
char newhost[1024];
sprintf(newhost, "%s:%d", m_host.str(), m_port);
replaceHeader(requestbuf, "Host", newhost);
//checkContentLength(requestbuf);
if(httptest_tracelevel > 5)
fprintf(m_ofile, "\n>>sending request to %s:%d\n", m_host.str(), m_port);
if(httptest_tracelevel > 10)
fprintf(m_ofile, "%s%s%s", sepstr, requestbuf.str(), sepstr);
socket2->write(requestbuf.str(), requestbuf.length());
StringBuffer respbuf;
Owned<IByteOutputStream> respstream = createOutputStream(respbuf);
receiveData(socket2.get(), respstream.get(), true);
if(httptest_tracelevel > 5)
fprintf(m_ofile, ">>received response from %s:%d:\n", m_host.str(), m_port);
if(httptest_tracelevel > 10)
fprintf(m_ofile, "%s%s%s", sepstr, respbuf.str(), sepstr);
m_client->write(respbuf.str(), respbuf.length());
fflush(m_ofile);
if(httptest_tracelevel > 5)
fprintf(m_ofile, ">>sent the response back to %s:%d:\n", peername, port);
socket2->shutdown();
socket2->close();
m_client->shutdown();
m_client->close();
}
catch(IException *excpt)
{
StringBuffer errMsg;
DBGLOG("%s", excpt->errorMessage(errMsg).str());
return -1;
}
catch(...)
{
DBGLOG("unknown exception");
return -1;
}
return 0;
}
示例6: sendRequest
int HttpClient::sendRequest(int times, HttpStat& stat, StringBuffer& req)
{
StringBuffer request;
if(req.length() <= 2)
{
throw MakeStringException(-1, "request too short");
}
bool endofheaders = false;
char c0 = req.charAt(0);
char c1 = req.charAt(1);
if(c0 == '\n')
request.append("\r\n");
else
request.append(c0);
if(c1 == '\n')
{
if(c0 == '\r')
request.append(c1);
else
{
request.append("\r\n");
if(c0 == '\n')
endofheaders = true;
}
}
else
request.append(c1);
unsigned seq = 2;
while(seq < req.length() && !endofheaders)
{
char c = req.charAt(seq);
if(c == '\n')
{
char c1 = req.charAt(seq - 1);
char c2 = req.charAt(seq - 2);
if(c1 == '\n' || (c1 == '\r' && c2 == '\n'))
endofheaders = true;
if(c1 != '\r')
request.append("\r\n");
else
request.append(c);
}
else
request.append(c);
seq++;
}
if(seq < req.length())
request.append(req.length() - seq, req.str() + seq);
if(httptest_tracelevel > 5)
fprintf(m_ofile, ">>sending out request to %s:%d for %d times\n", m_host.str(), m_port, times);
unsigned start = msTick();
int slowest = 0;
int fastest = 2147483647;
for(int i = 0; i < times; i++)
{
SocketEndpoint ep;
ep.set(m_host.str(), m_port);
Owned<ISocket> socket;
try
{
socket.setown(ISocket::connect(ep));
if(m_use_ssl && m_ssctx.get() != NULL)
{
Owned<ISecureSocket> securesocket = m_ssctx->createSecureSocket(socket.getLink());
int res = securesocket->secure_connect();
if(res >= 0)
{
socket.set(securesocket.get());
}
}
}
catch(IException *excpt)
{
StringBuffer errMsg;
DBGLOG("Error connecting to %s:%d - %d:%s", m_host.str(), m_port, excpt->errorCode(), excpt->errorMessage(errMsg).str());
continue;
}
catch(...)
{
DBGLOG("can't connect to %s:%d", m_host.str(), m_port);
continue;
}
if(socket.get() == NULL)
{
StringBuffer urlstr;
DBGLOG(">>Can't connect to %s", ep.getUrlStr(urlstr).str());
continue;
}
if(m_delay > 0)
sleep(m_delay);
//.........这里部分代码省略.........
示例7: main
int main(int argc,char **argv)
{
InitModuleObjects();
EnableSEHtoExceptionMapping();
#ifndef __64BIT__
// Restrict stack sizes on 32-bit systems
Thread::setDefaultStackSize(0x10000); // 64K stack (also set in windows DSP)
#endif
Owned<IFile> sentinelFile = createSentinelTarget();
removeSentinelFile(sentinelFile);
SocketEndpoint listenep;
unsigned sendbufsize = 0;
unsigned recvbufsize = 0;
int i = 1;
bool isdaemon = (memicmp(argv[0]+strlen(argv[0])-4,".exe",4)==0);
// bit of a kludge for windows - if .exe not specified then not daemon
bool locallisten = false;
const char *logdir=NULL;
bool requireauthenticate = false;
StringBuffer logDir;
StringBuffer instanceName;
//Get SSL Settings
const char * sslCertFile;
bool useSSL;
unsigned short dafsPort;//DAFILESRV_PORT or SECURE_DAFILESRV_PORT
querySecuritySettings(&useSSL, &dafsPort, &sslCertFile, NULL);
unsigned parallelRequestLimit = DEFAULT_PARALLELREQUESTLIMIT;
unsigned throttleDelayMs = DEFAULT_THROTTLEDELAYMS;
unsigned throttleCPULimit = DEFAULT_THROTTLECPULIMIT;
Owned<IPropertyTree> env = getHPCCEnvironment();
if (env)
{
StringBuffer dafilesrvPath("Software/DafilesrvProcess");
if (instanceName.length())
dafilesrvPath.appendf("[@name=\"%s\"]", instanceName.str());
IPropertyTree *daFileSrv = env->queryPropTree(dafilesrvPath);
if (daFileSrv)
{
// global DaFileSrv settings:
parallelRequestLimit = daFileSrv->getPropInt("@parallelRequestLimit", DEFAULT_PARALLELREQUESTLIMIT);
throttleDelayMs = daFileSrv->getPropInt("@throttleDelayMs", DEFAULT_THROTTLEDELAYMS);
throttleCPULimit = daFileSrv->getPropInt("@throttleCPULimit", DEFAULT_THROTTLECPULIMIT);
// any overrides by Instance definitions?
// NB: This won't work if netAddress is "." or if we start supporting hostnames there
StringBuffer ipStr;
queryHostIP().getIpText(ipStr);
VStringBuffer daFileSrvPath("Instance[@netAddress=\"%s\"]", ipStr.str());
IPropertyTree *dafileSrvInstance = daFileSrv->queryPropTree(daFileSrvPath);
if (dafileSrvInstance)
{
parallelRequestLimit = dafileSrvInstance->getPropInt("@parallelRequestLimit", parallelRequestLimit);
throttleDelayMs = dafileSrvInstance->getPropInt("@throttleDelayMs", throttleDelayMs);
throttleCPULimit = dafileSrvInstance->getPropInt("@throttleCPULimit", throttleCPULimit);
}
}
}
while (argc>i) {
if (stricmp(argv[i],"-D")==0) {
i++;
isdaemon = true;
}
else if (stricmp(argv[i],"-R")==0) { // for remote run
i++;
#ifdef _WIN32
isdaemon = false;
#else
isdaemon = true;
#endif
}
else if (stricmp(argv[i],"-A")==0) {
i++;
requireauthenticate = true;
}
else if ((argv[i][0]=='-')&&(toupper(argv[i][1])=='T')&&(!argv[i][2]||isdigit(argv[i][2]))) {
if (argv[i][2])
setDafsTrace(NULL,(byte)atoi(argv[i]+2));
i++;
isdaemon = false;
}
else if ((argc>i+1)&&(stricmp(argv[i],"-L")==0)) {
i++;
logDir.clear().append(argv[i++]);
}
else if ((argc>i+1)&&(stricmp(argv[i],"-I")==0)) {
i++;
instanceName.clear().append(argv[i++]);
}
else if (stricmp(argv[i],"-LOCAL")==0) {
i++;
locallisten = true;
}
else if (stricmp(argv[i],"-NOSSL")==0) {//overrides config setting
i++;
if (useSSL)
//.........这里部分代码省略.........
示例8: main
int main( int argc, char *argv[] )
{
#if defined(WIN32) && defined(_DEBUG)
int tmpFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG );
tmpFlag |= _CRTDBG_LEAK_CHECK_DF;
_CrtSetDbgFlag( tmpFlag );
#endif
InitModuleObjects();
addAbortHandler(ControlHandler);
EnableSEHtoExceptionMapping();
dummyProc();
#ifndef __64BIT__
Thread::setDefaultStackSize(0x10000); // NB under windows requires linker setting (/stack:)
#endif
#ifdef _WIN32
Owned<CReleaseMutex> globalNamedMutex;
#endif
if (globals)
globals->Release();
{
Owned<IFile> iFile = createIFile("thor.xml");
globals = iFile->exists() ? createPTree(*iFile, ipt_caseInsensitive) : createPTree("Thor", ipt_caseInsensitive);
}
unsigned multiThorMemoryThreshold = 0;
try {
if (argc==1)
{
usage();
return 1;
}
cmdArgs = argv+1;
mergeCmdParams(globals);
cmdArgs = argv+1;
const char *master = globals->queryProp("@MASTER");
if (!master)
usage();
const char *slave = globals->queryProp("@SLAVE");
if (slave)
{
slfEp.set(slave);
localHostToNIC(slfEp);
}
else
slfEp.setLocalHost(0);
if (globals->hasProp("@SLAVENUM"))
mySlaveNum = atoi(globals->queryProp("@SLAVENUM"));
else
mySlaveNum = slfEp.port; // shouldn't happen, provided by script
setMachinePortBase(slfEp.port);
slfEp.port = getMachinePortBase();
startSlaveLog();
startMPServer(getFixedPort(TPORT_mp));
#ifdef USE_MP_LOG
startLogMsgParentReceiver();
LOG(MCdebugProgress, thorJob, "MPServer started on port %d", getFixedPort(TPORT_mp));
#endif
SocketEndpoint masterEp(master);
localHostToNIC(masterEp);
setMasterPortBase(masterEp.port);
markNodeCentral(masterEp);
if (RegisterSelf(masterEp))
{
#define ISDALICLIENT // JCSMORE plugins *can* access dali - though I think we should probably prohibit somehow.
#ifdef ISDALICLIENT
const char *daliServers = globals->queryProp("@DALISERVERS");
if (!daliServers)
{
LOG(MCerror, thorJob, "No Dali server list specified\n");
return 1;
}
Owned<IGroup> serverGroup = createIGroup(daliServers, DALI_SERVER_PORT);
unsigned retry = 0;
loop {
try {
LOG(MCdebugProgress, thorJob, "calling initClientProcess");
initClientProcess(serverGroup,DCR_ThorSlave, getFixedPort(TPORT_mp));
break;
}
catch (IJSOCK_Exception *e) {
if ((e->errorCode()!=JSOCKERR_port_in_use))
throw;
FLLOG(MCexception(e), thorJob, e,"InitClientProcess");
if (retry++>10)
throw;
e->Release();
LOG(MCdebugProgress, thorJob, "Retrying");
Sleep(retry*2000);
}
//.........这里部分代码省略.........
示例9: GetServerAddr
void GetServerAddr(SocketEndpoint &ep)
{
ep.set(hostname,hostport);
}
示例10: main
int main(int argc,char **argv)
{
InitModuleObjects();
EnableSEHtoExceptionMapping();
#ifndef __64BIT__
Thread::setDefaultStackSize(0x10000); // 64K stack (also set in windows DSP)
#endif
StringBuffer logDir;
#ifdef _WIN32
logDir.append("c:\\");
#else
if (checkDirExists("/c$"))
logDir.append("/c$/");
#endif
Owned<IFile> sentinelFile = createSentinelTarget();
removeSentinelFile(sentinelFile);
SocketEndpoint listenep;
unsigned sendbufsize = 0;
unsigned recvbufsize = 0;
int i = 1;
bool isdaemon = (memicmp(argv[0]+strlen(argv[0])-4,".exe",4)==0);
// bit of a kludge for windows - if .exe not specified then not daemon
bool locallisten = false;
const char *logdir=NULL;
bool requireauthenticate = false;
while (argc>i) {
if (stricmp(argv[i],"-D")==0) {
i++;
isdaemon = true;
}
else if (stricmp(argv[i],"-R")==0) { // for remote run
i++;
#ifdef _WIN32
isdaemon = false;
#else
isdaemon = true;
#endif
}
else if (stricmp(argv[i],"-A")==0) {
i++;
requireauthenticate = true;
}
else if ((argv[i][0]=='-')&&(toupper(argv[i][1])=='T')&&(!argv[i][2]||isdigit(argv[i][2]))) {
if (argv[i][2])
setDafsTrace(NULL,(byte)atoi(argv[i]+2));
i++;
isdaemon = false;
}
else if ((argc>i+1)&&(stricmp(argv[i],"-L")==0)) {
i++;
logDir.clear().append(argv[i++]);
addPathSepChar(logDir);
}
else if (stricmp(argv[i],"-LOCAL")==0) {
i++;
locallisten = true;
}
else
break;
}
#ifdef _WIN32
if ((argc>i)&&(stricmp(argv[i],"-install")==0)) {
if (installService(DAFS_SERVICE_NAME,DAFS_SERVICE_DISPLAY_NAME,NULL)) {
PROGLOG(DAFS_SERVICE_DISPLAY_NAME " Installed");
return 0;
}
return 1;
}
if ((argc>i)&&(stricmp(argv[i],"-remove")==0)) {
if (uninstallService(DAFS_SERVICE_NAME,DAFS_SERVICE_DISPLAY_NAME)) {
PROGLOG(DAFS_SERVICE_DISPLAY_NAME " Uninstalled");
return 0;
}
return 1;
}
#endif
if (argc == i)
listenep.port = DAFILESRV_PORT;
else {
if (strchr(argv[i],'.')||!isdigit(argv[i][0]))
listenep.set(argv[i],DAFILESRV_PORT);
else
listenep.port = atoi(argv[i]);
if (listenep.port==0) {
usage();
exit(-1);
}
sendbufsize = (argc>i+1)?(atoi(argv[i+1])*1024):0;
recvbufsize = (argc>i+2)?(atoi(argv[i+2])*1024):0;
}
if (isdaemon) {
#ifdef _WIN32
class cserv: public CService
{
bool stopped;
bool started;
//.........这里部分代码省略.........
示例11: testIORemote
void testIORemote()
{
SocketEndpoint ep;
ep.set(server, 7100);
testIO(nr10pct, &ep);
}