当前位置: 首页>>代码示例>>C++>>正文


C++ PSOCK_END函数代码示例

本文整理汇总了C++中PSOCK_END函数的典型用法代码示例。如果您正苦于以下问题:C++ PSOCK_END函数的具体用法?C++ PSOCK_END怎么用?C++ PSOCK_END使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了PSOCK_END函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: PT_THREAD

/*---------------------------------------------------------------------------*/
static
PT_THREAD(neighbors(struct httpd_state *s, char *ptr))
{
  PSOCK_BEGIN(&s->sout);

  for(s->u.ptr = nbr_table_head(ds6_neighbors);
      s->u.ptr != NULL;
      s->u.ptr = nbr_table_next(ds6_neighbors, s->u.ptr)) {
    PSOCK_GENERATOR_SEND(&s->sout, make_neighbor, s);
  }

  PSOCK_GENERATOR_SEND(&s->sout, make_neighbor_roomfor, s);
  PSOCK_END(&s->sout);
}
开发者ID:ADVANSEE,项目名称:mist,代码行数:15,代码来源:httpd-cgi.c

示例2: PT_THREAD

/*---------------------------------------------------------------------------*/
static PT_THREAD (send_file (struct httpd_state *s))
{
  PSOCK_BEGIN (&s->sout);

  do 
  {
    PSOCK_GENERATOR_SEND (&s->sout, generate_part_of_file, s);
    s->file.len -= s->len;
    s->file.data += s->len;
  } 
  while (s->file.len > 0);

  PSOCK_END (&s->sout);
}
开发者ID:j0t4,项目名称:espardino,代码行数:15,代码来源:httpd.c

示例3: PT_THREAD

static
PT_THREAD(send_buf(struct httpd_ws_state *s))
{
	memcpy(s->outbuf, buf, HTTPD_OUTBUF_SIZE);
	s->outbuf_pos = strlen(buf);
	buf_lock = 0;

	PSOCK_BEGIN(&s->sout);
	if(s->outbuf_pos > 0) {
		SEND_STRING(&s->sout, s->outbuf, s->outbuf_pos);
		s->outbuf_pos = 0;
	}
	PSOCK_END(&s->sout);
}
开发者ID:malvira,项目名称:rplstats,代码行数:14,代码来源:rplstats.c

示例4: PT_THREAD

/*---------------------------------------------------------------------------*/
static
PT_THREAD(create_test_session(struct psock *p))
{
  /*
   * A protosocket's protothread must start with a PSOCK_BEGIN(), with
   * the protosocket as argument.
   */
  PSOCK_BEGIN(p);

  /*
   * Here we define all the thread local variables that we need to
   * utilize.
   */
  static RequestSession request;
  static AcceptSession accept;
  
  PSOCK_WAIT_UNTIL(p,PSOCK_NEWDATA(p));
  if(PSOCK_NEWDATA(p)){
    /*
     * We read data from the buffer now that it has arrived.
     * Using memcpy we store it in our local variable.
     */
    PSOCK_READBUF(p);
    memcpy(&request,buffer,sizeof(request));

    TEST_AMOUNT = (int) request.NumOfPackets;
    UDP_SENDER_PORT = (int) request.SenderPort;
    UDP_RECEIVER_PORT = (int) request.RecieverPort;
    
    /*
     * Prints for debugging.
     */
    printf("Type: %"PRIu32"\n",request.Type);
    printf("SenderPort: %"PRIu32"\n",request.SenderPort);
    printf("ReceiverPort: %"PRIu32"\n",request.RecieverPort);
    printf("SenderAddress: %08x,%x\n",request.SenderAddress,request.SenderMBZ);
    printf("ReceiverAddress: %08x,%x\n",request.RecieverAddress,request.RecieverMBZ);
    printf("StartTime: %u\n",request.StartTime.Second);
    
    accept.Accept = 0;
    accept.Port = request.RecieverPort; 

    PSOCK_SEND(p, &accept, sizeof(accept));
    PSOCK_SEND(p, &accept, sizeof(accept));
  } else {
    printf("Timed out!\n");
  }  
  state = 3;
  PSOCK_END(p);
}
开发者ID:DrThyme,项目名称:TWAMP-Measurement-IoT,代码行数:51,代码来源:twamp_light_reflector.c

示例5: PT_THREAD

/*---------------------------------------------------------------------------*/
static
PT_THREAD(tcp_stats(struct httpd_state *s, char *ptr))
{

  PSOCK_BEGIN(&s->sout);

  for(s->count = 0; s->count < UIP_CONNS; ++s->count) {
    if((uip_conns[s->count].tcpstateflags & UIP_TS_MASK) != UIP_CLOSED) {
      PSOCK_GENERATOR_SEND(&s->sout, generate_tcp_stats, s);
    }
  }

  PSOCK_END(&s->sout);
}
开发者ID:suix2,项目名称:InUW,代码行数:15,代码来源:httpd-cgi.c

示例6: handle_connection

/*
 * This is the protosocket function that handles the communication. A
 * protosocket function must always return an int, but must never
 * explicitly return - all return statements are hidden in the PSOCK
 * macros.
 */
static int
handle_connection(struct hello_world_state *s)
{
  PSOCK_BEGIN(&s->p);

  PSOCK_SEND_STR(&s->p, "Hello. What is your name?\n");
  PSOCK_READTO(&s->p, '\n');
  strncpy(s->name, s->inputbuffer, sizeof(s->name));
  PSOCK_SEND_STR(&s->p, "Hello ");
  PSOCK_SEND_STR(&s->p, s->name);
  PSOCK_CLOSE(&s->p);
  
  PSOCK_END(&s->p);
}
开发者ID:MrMehdi,项目名称:ARM_LPC1788,代码行数:20,代码来源:hello-world.c

示例7: PT_THREAD

static PT_THREAD( net_stats ( struct httpd_state *s, char *ptr ) )
{
	PSOCK_BEGIN( &s->sout );
	( void ) ptr;
#if UIP_STATISTICS
	for( s->count = 0; s->count < sizeof(uip_stat) / sizeof(uip_stats_t); ++s->count )
	{
		PSOCK_GENERATOR_SEND( &s->sout, generate_net_stats, s );
	}

#endif /* UIP_STATISTICS */

	PSOCK_END( &s->sout );
}
开发者ID:DIYzzuzpb,项目名称:PIC32USB,代码行数:14,代码来源:httpd-cgi.c

示例8: PT_THREAD

static
PT_THREAD(handle_connection(struct psock *p))
{
  PSOCK_BEGIN(p);
  //PSOCK_SEND_STR(p, "Type something!\n");
  leds_on(LEDS_RED);
  PSOCK_READTO(p, '\n');
  printf("RX=%s", buf);
  //PSOCK_SEND_STR(p, "Got: ");
  //PSOCK_SEND(p, buf, PSOCK_DATALEN(p));
  //PSOCK_SEND_STR(p, "EOL\r\n");
  //PSOCK_CLOSE(p);
  PSOCK_END(p);
}
开发者ID:1847123212,项目名称:contiki,代码行数:14,代码来源:server.c

示例9: PT_THREAD

static
PT_THREAD(handle_emu_in(struct httpd_state *s, RoverAction last)) {
	static int c = 0;
	PSOCK_BEGIN(&s->sin);
	
	f(8, "Input______________ ", &c);
	PSOCK_READTO(&s->sin, 0xFF);
	f(8, "Input ", &c);
	//int len = PSOCK_DATALEN(&s->sin)-1;
	// Report the data we got
	gotData(last, s->inputbuf);
	s->state = STATE_WAITING;
	
	PSOCK_END(&s->sin);
}
开发者ID:Carrotman42,项目名称:cs4534,代码行数:15,代码来源:httpd.c

示例10: handle_connection

/*
 * This is the protosocket function that handles the communication. A
 * protosocket function must always return an int, but must never
 * explicitly return - all return statements are hidden in the PSOCK
 * macros.
 */
static int handle_connection(struct socket_app_state *s){
  PSOCK_BEGIN(&s->p);
  while(1){
	PSOCK_READTO(&s->p, '\n');
	if(*s->inputbuffer=='q'){
		PSOCK_SEND_STR(&s->p, "\n");
		break;
	}
	handleCommand(s->inputbuffer, s->outputbuffer);
	memset(s->inputbuffer, 0x00, SOCKET_BUFFER_LENGTH);
	PSOCK_SEND_STR(&s->p, s->outputbuffer);
  }
  PSOCK_CLOSE(&s->p);
  PSOCK_END(&s->p);
}
开发者ID:hmeyer,项目名称:RadioClock,代码行数:21,代码来源:socketapp.c

示例11: PT_THREAD

/*---------------------------------------------------------------------------*/
static
PT_THREAD(generate_routes(struct httpd_state *s))
{
  static int i;
  PSOCK_BEGIN(&s->sout);

  SEND_STRING(&s->sout, TOP);

  blen = 0;
  ADD("Neighbors<pre>");
  for(i = 0; i < UIP_DS6_NBR_NB; i++) {
    if(uip_ds6_nbr_cache[i].isused) {
      ipaddr_add(&uip_ds6_nbr_cache[i].ipaddr);
      ADD("\n");
      if(blen > sizeof(buf) - 45) {
        SEND_STRING(&s->sout, buf);
        blen = 0;
      }
    }
  }

  ADD("</pre>Routes<pre>");
  SEND_STRING(&s->sout, buf);
  blen = 0;
  for(i = 0; i < UIP_DS6_ROUTE_NB; i++) {
    if(uip_ds6_routing_table[i].isused) {
      ipaddr_add(&uip_ds6_routing_table[i].ipaddr);
      ADD("/%u (via ", uip_ds6_routing_table[i].length);
      ipaddr_add(&uip_ds6_routing_table[i].nexthop);
      if(uip_ds6_routing_table[i].state.lifetime < 600) {
        ADD(") %lus\n", uip_ds6_routing_table[i].state.lifetime);
      } else {
        ADD(")\n");
      }
      SEND_STRING(&s->sout, buf);
      blen = 0;
    }
  }
  ADD("</pre>");
//if(blen > 0) {
    SEND_STRING(&s->sout, buf);
// blen = 0;
//}

  SEND_STRING(&s->sout, BOTTOM);

  PSOCK_END(&s->sout);
}
开发者ID:CaptFrank,项目名称:contiki-stm32w,代码行数:49,代码来源:border-router.c

示例12: PT_THREAD

/*---------------------------------------------------------------------------*/
static
PT_THREAD(handle_input(struct httpd_state *s))
{
  PSOCK_BEGIN(&s->sin);

  PSOCK_READTO(&s->sin, ISO_space);

  
  if(strncmp(s->inputbuf, http_get, 4) != 0) {
    PSOCK_CLOSE_EXIT(&s->sin);
  }
  PSOCK_READTO(&s->sin, ISO_space);

  if(s->inputbuf[0] != ISO_slash) {
    PSOCK_CLOSE_EXIT(&s->sin);
  }

  if(s->inputbuf[1] == ISO_space) {
    strncpy(s->filename, http_index_html, sizeof(s->filename));
  } else {

    s->inputbuf[PSOCK_DATALEN(&s->sin) - 1] = 0;

    /* Process any form input being sent to the server. */
    {
        // Form input called here
        extern void vApplicationProcessFormInput( char *pcInputString, long xInputLength );
        vApplicationProcessFormInput( s->inputbuf, PSOCK_DATALEN(&s->sin) );
    }

    strncpy(s->filename, &s->inputbuf[0], sizeof(s->filename));
  }

  /*  httpd_log_file(uip_conn->ripaddr, s->filename);*/
  
  s->state = STATE_OUTPUT;

  while(1) {
    PSOCK_READTO(&s->sin, ISO_nl);

    if(strncmp(s->inputbuf, http_referer, 8) == 0) {
      s->inputbuf[PSOCK_DATALEN(&s->sin) - 2] = 0;
      /*      httpd_log(&s->inputbuf[9]);*/
    }
  }
  
  PSOCK_END(&s->sin);
}
开发者ID:dray92,项目名称:EE-472,代码行数:49,代码来源:httpd.c

示例13: handle_connection

/*---------------------------------------------------------------------------*/
static int
handle_connection(struct psock *p)
{
  PSOCK_BEGIN(p);

  PSOCK_SEND_STR(p, "GET / HTTP/1.0\r\n");
  PSOCK_SEND_STR(p, "Server: Contiki example protosocket client\r\n");
  PSOCK_SEND_STR(p, "\r\n");

  while(1) {
    PSOCK_READTO(p, '\n');
    printf("Got: %s", buffer);
  }
  
  PSOCK_END(p);
}
开发者ID:1uk3,项目名称:contiki,代码行数:17,代码来源:example-psock-client.c

示例14: PT_THREAD

static
PT_THREAD(send_values(struct httpd_state *s))
{
  PSOCK_BEGIN(&s->sout);

  SEND_STRING(&s->sout, TOP);

  if(strncmp(s->filename, "/index", 6) == 0 ||
     s->filename[1] == '\0') {
    /* Default page: show latest sensor values as text (does not
       require Internet connection to Google for charts). */
    blen = 0;
    ADD("<h1>Websense</h1>\n");
#if CONTIKI_TARGET_SKY
    ADD("<h2>Current readings</h2>\n"
        "Light: %u<br>"
        "Temperature: %u&deg; C",
        get_light(), get_temp());
#endif
    SEND_STRING(&s->sout, buf);
  } else if(s->filename[1] == '0') {
    /* Turn off leds */
    leds_off(LEDS_ALL);
    SEND_STRING(&s->sout, "Turned off leds!");

  } else if(s->filename[1] == '1') {
    /* Turn on leds */
    leds_on(LEDS_ALL);
    SEND_STRING(&s->sout, "Turned on leds!");

  } else {
#if CONTIKI_TARGET_SKY
    if(s->filename[1] != 't') {
      generate_chart("Light", "Light", 0, 500, light1);
      SEND_STRING(&s->sout, buf);
    }
    if(s->filename[1] != 'l') {
      generate_chart("Temperature", "Celsius", 15, 50, temperature);
      SEND_STRING(&s->sout, buf);
    }
#endif
  }

  SEND_STRING(&s->sout, BOTTOM);

  PSOCK_END(&s->sout);
}
开发者ID:Ayesha-N,项目名称:6lbr,代码行数:47,代码来源:sky-websense.c

示例15: handle_connection

static int handle_connection(struct webserver_state *s)
{
	PSOCK_BEGIN(&s->p);

	// the incoming GET request will have the following format:
	// GET / HTTP/1.1 ....
	// we have to parse this string to determine the resource being requested
	// if the requested resource is not the root webpage ('/') then,
	// GET /<resource name> HTTP/1.1 ....
	// we should parse the specific resource and react appropriately

	// read incoming data until we read a space character
	PSOCK_READTO(&s->p, ISO_space);

	// parse the data to determine if it was a GET request
	if(strncmp(s->inputbuf, http_get, 4) != 0) {
		PSOCK_CLOSE_EXIT(&s->p);
	}

	// continue reading until the next space character
	PSOCK_READTO(&s->p, ISO_space);

	// determine the requested resource
	// in this case, we check if the request was for the '/' root page
	// AKA index.html
	if(s->inputbuf[0] != ISO_slash) {
		// request for unknown webpage, close and exit
		PSOCK_CLOSE_EXIT(&s->p);
	}

	if(s->inputbuf[1] != ISO_space) {
		// request for unavailable resource
		// not supported, modify to add support for additional resources
		PSOCK_CLOSE_EXIT(&s->p);
	}

	lockstate = lockstate+1;

        PSOCK_SEND_STR(&s->p, "HTTP/1.1 200 OK\r\n");
	PSOCK_SEND_STR(&s->p, "Content-Type: text/html\r\n");
	PSOCK_SEND_STR(&s->p, "\r\n");
	PSOCK_SEND_STR(&s->p, "Hello World, I am WiShield");
	PSOCK_SEND_STR(&s->p, "<center><h1>Hello World!! I am Matt's WiShield.  Find me in webserver.c under PSOCK_SEND_STR.</h1></center>");
        PSOCK_GENERATOR_SEND(&s->p, fill_buf, 0);
	PSOCK_CLOSE(&s->p);
	PSOCK_END(&s->p);
}
开发者ID:shinsyotta,项目名称:Unlock,代码行数:47,代码来源:webserver.c


注:本文中的PSOCK_END函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。