root/nano-RK/tools/SLIPstream/SLIPstream-client/main.c

Revision 324, 0.7 kB (checked in by agr, 8 months ago)

slip code update

Line 
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <slipstream.h>
5
6 #define NONBLOCKING  0
7 #define BLOCKING     1
8
9
10 int main (int argc, char *argv[])
11 {
12   char buffer[128];
13   int v,cnt,i;
14
15   if (argc != 3) {
16     printf ("Usage: server port\n");
17     exit (1);
18   }
19
20   v=slipstream_open(argv[1],atoi(argv[2]),NONBLOCKING);
21  
22   cnt = 0;
23   while (1) {
24     cnt++;
25     sprintf (buffer, "This is a sample slip string: Count %d\n", cnt);
26
27     v=slipstream_send(buffer,strlen(buffer)+1);
28     if (v == 0) printf( "Error sending\n" );
29
30     v=slipstream_receive( buffer );
31     if (v > 0) {
32       printf ("Got: ");
33       for (i = 0; i < v; i++)
34         printf ("%c", buffer[i]);
35       printf ("\n");
36     }
37 // Pause for 1 second
38     sleep (1);
39   }
40
41
42
43 }
44
Note: See TracBrowser for help on using the browser.