void GameNetDelegate::connectByIpPort(const char *ip, unsigned short port) { CCInetAddress oAddres; oAddres.setIp(ip); oAddres.setPort(port); setInetAddress(oAddres); connect(); }
static int brl_construct (BrailleDisplay *brl, char **parameters, const char *device) { if (!allocateCommandDescriptors()) return 0; inputLength = 0; inputStart = 0; inputEnd = 0; outputLength = 0; if (isQualifiedDevice(&device, "client")) { static const ModeEntry clientModeEntry = { #ifdef AF_LOCAL requestLocalConnection, #endif /* AF_LOCAL */ #ifdef __MINGW32__ requestNamedPipeConnection, #endif /* __MINGW32__ */ requestInetConnection }; mode = &clientModeEntry; } else if (isQualifiedDevice(&device, "server")) { static const ModeEntry serverModeEntry = { #ifdef AF_LOCAL acceptLocalConnection, #endif /* AF_LOCAL */ #ifdef __MINGW32__ acceptNamedPipeConnection, #endif /* __MINGW32__ */ acceptInetConnection }; mode = &serverModeEntry; } else { unsupportedDevice(device); goto failed; } if (!*device) device = VR_DEFAULT_SOCKET; #ifdef AF_LOCAL if (device[0] == '/') { struct sockaddr_un address; if (setLocalAddress(device, &address)) { fileDescriptor = mode->getLocalConnection(&address); } } else #endif /* AF_LOCAL */ #ifdef __MINGW32__ if (device[0] == '\\') { fileDescriptor = mode->getNamedPipeConnection(device); } else { static WSADATA wsadata; if (WSAStartup(MAKEWORD(1, 1), &wsadata)) { logWindowsSystemError("socket library start"); goto failed; } } #endif /* __MINGW32__ */ { struct sockaddr_in address; if (setInetAddress(device, &address)) { fileDescriptor = mode->getInetConnection(&address); } } if (fileDescriptor != -1) { char *line = NULL; while (1) { if (line) free(line); if ((line = readCommandLine())) { const char *word; logMessage(LOG_DEBUG, "command received: %s", line); if ((word = strtok(line, inputDelimiters))) { if (testWord(word, "cells")) { if (dimensionsChanged(brl)) { free(line); return 1; } } else if (testWord(word, "quit")) { break; } else { logMessage(LOG_WARNING, "unexpected command: %s", word); } } } else { asyncWait(1000); } } if (line) free(line); close(fileDescriptor); fileDescriptor = -1; } failed: deallocateCommandDescriptors(); return 0; }