Пример #1
0
static int inet_send(struct socket *sock, void *buff, int len, int nonblock,
		     unsigned int flags)
{
    if (flags != 0)
	return -EINVAL;

    return inet_write(sock, (char *) buff, len, nonblock);
}
Пример #2
0
static void cmd_connect(Stream *chp, int argc, char* argv[])
{
   if (argc < 2) {
      chprintf(chp, "Usage: connect <host> <port>\r\n");
      return;
   }
   int port = atoi(argv[1]);
   int res = inet_open(argv[0], port);
   if (res == 0) {
      chprintf(chp, "**** Connected to %s, Ctrl-D to exit **** \r\n", argv[0]);
      inet_mon_on(true);
      inet_disable_read(true);
      sleep(10);
      while (!shellGetLine(chp, buf, BUFSIZE) && inet_is_connected())  
          inet_write(buf);
      inet_close();
      inet_mon_on(false);
      inet_disable_read(false);
   }
   else
     chprintf(chp, "ERROR. Cannot connect: %d\r\n", res);
}