int main(int argc, char *argv[]) { ros::Publisher pub[TOPIC_NR]; int port, plane; int sock, asock; struct sigaction act; memset(&act, 0, sizeof(act)); act.sa_handler = stopChildProcess; if (sigaction(SIGTERM, &act, NULL) == -1) { perror("sigaction"); return -1; } ros::init(argc, argv, NODE_NAME); ros::NodeHandle node; pub[0] = node.advertise<tablet_socket_msgs::gear_cmd>("gear_cmd", 1); pub[1] = node.advertise<tablet_socket_msgs::mode_cmd>("mode_cmd", 1); pub[2] = node.advertise<tablet_socket_msgs::route_cmd>("route_cmd", 1); pub[3] = node.advertise<geometry_msgs::PoseStamped>("gnss_pose", 1); pub[4] = node.advertise<std_msgs::Bool>("gnss_stat", 1); node.param<int>("tablet_receiver/port", port, DEFAULT_PORT); node.param<int>("tablet_receiver/plane", plane, DEFAULT_PLANE); fprintf(stderr, "listen port=%d\n", port); geo.set_plane(plane); //get connect to android sock = -1; sigaction(SIGINT, NULL, &act); act.sa_flags &= ~SA_RESTART; sigaction(SIGINT, &act, NULL); while (getConnect(port, &sock, &asock) != -1) { struct timeval tv[2]; double sec; int count; fprintf(stderr, "get connect.\n"); gettimeofday(tv, NULL); for (count = 0; ; count++) { if(getSensorValue(asock, pub) == -1) break; if(sendSignal(asock) == -1) break; } close(asock); gettimeofday(tv+1, NULL); sec = (tv[1].tv_sec - tv[0].tv_sec) + (tv[1].tv_usec - tv[0].tv_usec) / 1000000.0; fprintf(stderr, "done, %f sec\n",sec); } return 0; }
int main(void){ // socket int sock; // file size int fileSize = 0; // file pointer FILE* fp; //counter int count = 0; // open the file fp = fopen("rec.raw", "wb" ); if( fp == NULL ){ fputs( "ERROR: File\n", stderr ); exit( EXIT_FAILURE ); } // connect client sock = getConnect(12345); printf("connected\n"); while(count < 100){ // get file size fileSize = getFileSize(sock); if(fileSize == -1){ printf("ERROR\n"); break; } else{ printf("file size: %d\n", fileSize); } // get sound data if(getSoundFile(sock, fileSize, fp) == -1){ break; } count++; } //file close fclose(fp); // close socket close(sock); return 0; }
/** * <EN> * @brief Open an input stream (required) * * This function should open a new audio stream for input. * You may open a capture device, open an audio file, or wait for * connection with other network client at this function. * * If this function returns FALSE, Julius will exit recognition loop. * * JuliusLib: this will be called at j_open_stream(). * * @param pathname [in] file / device name to open or NULL for default * * @return TRUE on success, FALSE on failure. * </EN> * <JA> * @brief 入力音声ストリームを開く(必須) * * 入力音声ストリームを新規に開く.通常,デバイスやファイルのオープン, * ネットワーククライアントからの接続などをここで行う. * * FALSE を返したとき,Julius は認識ループを抜ける. * * JuliusLib: この関数は j_open_stream() 内で呼ばれる. * * @param pathname [in] 開くファイルあるいはデバイス名,NULL ならデフォルト * * @return 成功時 TRUE,失敗時 FALSE を返す. * </JA> */ boolean adin_open(char *pathname) { /* do open the device */ int fmt; int stereo; int ret; int s; char buf[2]; fprintf(stderr, "[Androidnet]: Connection Waiting....\n"); // connect client sock = getConnect(12345); fprintf(stderr, "[Androidnet]: Connected !\n"); return(TRUE); }
int main(void){ int answer; //get connect to android getConnect(12336); printf("get connect.\n"); while(1){ printf("send picture\n"); if(sendPicture() == -1) break; //answer = 11; //send(sock, &answer, sizeof(answer), 0); printf("ans\n"); recv(sock, &answer, sizeof(answer), 0); printf("answer: %d\n", answer); sleep(1); } return 0; }
/** * Pool construct * * create resource when reslist need more resource */ static apr_status_t pool_construct(void** resource, void* params, apr_pool_t* pool) { server_rec *s = (server_rec*) params; redis_cfg *redis_config = (redis_cfg*) ap_get_module_config(s->module_config, &apachelog_module); struct timeval timeout = { redis_config->redis_timeout, redis_config->redis_timeout_ms }; redisContext *ctx = NULL; ctx = getConnect(redis_config->redis_host, redis_config->redis_port, timeout, s); if (ctx == NULL) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, "[APACHELOG][REDIS CONNECTION FAIL][%s][%d]", redis_config->redis_host, redis_config->redis_port); return APR_EGENERAL; } if (redis_config->redis_pass != NULL && strlen(redis_config->redis_pass) > 0) { if (redis_auth(ctx, redis_config->redis_pass, s) == DECLINED) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, "[APACHELOG][REDIS AUTH FAIL][%s][%d]", redis_config->redis_host, redis_config->redis_port); redisFree(ctx); return APR_EGENERAL; } } *resource = ctx; return APR_SUCCESS; }
LRESULT RecentHubsFrame::onCustomDraw(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/) { return CDRF_DODEFAULT; #ifdef SCALOLAZ_USE_COLOR_HUB_IN_FAV LPNMLVCUSTOMDRAW cd = reinterpret_cast<LPNMLVCUSTOMDRAW>(pnmh); switch (cd->nmcd.dwDrawStage) { case CDDS_PREPAINT: return CDRF_NOTIFYITEMDRAW; case CDDS_ITEMPREPAINT: { cd->clrText = Colors::textColor; const auto fhe = FavoriteManager::getInstance()->getFavoriteHubEntry(getRecentServer((int)cd->nmcd.dwItemSpec)); if (fhe) { if (fhe->getConnect()) { cd->clrTextBk = SETTING(HUB_IN_FAV_CONNECT_BK_COLOR); } else { cd->clrTextBk = SETTING(HUB_IN_FAV_BK_COLOR); } } #ifdef FLYLINKDC_USE_LIST_VIEW_MATTRESS Colors::alternationBkColor(cd); // [+] IRainman #endif return CDRF_NEWFONT | CDRF_NOTIFYSUBITEMDRAW; } default: return CDRF_DODEFAULT; } #endif }
int CGameModule::sendMsgToClient(const char* msgData, const unsigned int msgLen, unsigned short protocolId, const char* userName, unsigned int serviceId, unsigned short moduleId, unsigned int msgId) { int rc = (userName != NULL) ? m_service->sendMsgToClient(msgData, msgLen, msgId, serviceId, moduleId, protocolId, getConnect(userName)) : InvalidParam; if (rc != Success) ReleaseErrorLog("send client message error2, msgLen = %u, serviceId = %d, moduleId = %d, protocolId = %d, rc = %d, userName = %s", msgLen, serviceId, moduleId, protocolId, rc, (userName != NULL) ? userName : ""); return rc; }