bool SetupView::CheckSetup() { if (*fServerAddress->Text() && *fQueuePort->Text()) { BNetEndpoint* ep = new BNetEndpoint(SOCK_STREAM); if (ep->InitCheck() == B_NO_ERROR) { uint16 port = atoi(fQueuePort->Text()); if (! port) port = 9100; if (ep->Connect(fServerAddress->Text(), port) != B_OK) { BString text; text << "Fail to connect to " << fServerAddress->Text() << ":" << (int) port << "!"; BAlert* alert = new BAlert("", text.String(), "OK"); alert->Go(); return false; }; char str[256]; sprintf(str, "%s:%d", fServerAddress->Text(), port); fPrinterDirectory->WriteAttr("transport_address", B_STRING_TYPE, 0, str, strlen(str) + 1); return true; }; }; BAlert* alert = new BAlert("", "please input parameters.", "OK"); alert->Go(); return false; }
BArchivable* BNetEndpoint::Instantiate(BMessage* archive) { if (!archive) return NULL; if (!validate_instantiation(archive, "BNetEndpoint")) return NULL; BNetEndpoint* endpoint = new BNetEndpoint(archive); if (endpoint && endpoint->InitCheck() == B_OK) return endpoint; delete endpoint; return NULL; }
int32 ReceiveLoop(void *pDummy) { LogWindow *logWindow; BNetEndpoint bneNapsterPort; BNetEndpoint *bneReceived; thread_id acceptedThread; logWindow = (LogWindow *)pDummy; bneNapsterPort.Bind(atol(logWindow->myPreferences->GetPort())); if(bneNapsterPort.InitCheck() != B_OK) return 0; bneNapsterPort.Listen(); for ( ; ; ) { bneReceived = bneNapsterPort.Accept(); logWindow->netEndpoint = bneReceived; acceptedThread = spawn_thread(DoAccept, "Post-Connection Accept", B_LOW_PRIORITY, logWindow); resume_thread(acceptedThread); } return(0); }