Initial commit
[jamendo] / branches / nota-show-app / src / ts7200 / test_client.c
1 #ifndef NOTAIO_H
2 #define NOTAIO_H
3
4 #include <stdio.h>
5 #include <errno.h>
6 #include <unistd.h>
7 #include <stdlib.h>
8
9 #define USE_H_IN3       //h_in2 or h_in3
10
11 #ifdef USE_H_IN3
12 #include "nota3/h_in/h_bsdapi.h"
13 #else
14 #include "h_in.h"
15 #endif
16
17 #define SID 1
18 #define DEFAULT_PORT 0
19
20 int main()
21 {
22     int sock, err;
23     char buf;
24     nota_addr_t addr = { SID, DEFAULT_PORT };
25     sock = Hsocket( Hgetinstance(), AF_NOTA, SOCK_STREAM, 0 );
26     if(sock < 0)
27     {
28         perror( "Hsocket" );
29         exit( 1 );
30     }
31
32     err = Hconnect( Hgetinstance(), sock, (struct sockaddr*) &addr, sizeof(addr) );
33     if( err != 0 ) 
34     {
35         Hclose( Hgetinstance(), sock );
36         perror( "Hconnect" );
37         exit( 1 );
38     }
39
40     buf = 'a';
41     err = Hsend( Hgetinstance(), sock, &buf, 1, 0 );
42     if(err != 1) {
43         Hclose( Hgetinstance(), sock );
44         perror( "Hsend" );
45         exit( 1 );
46     }
47
48     printf( "Wyslano %d znakow: %c\n", err, buf );
49     Hclose( Hgetinstance(), sock );
50
51     return 0;
52 }
53
54 #endif