Initial commit
[jamendo] / branches / nota-show-app / src / ts7200 / test_client.c
diff --git a/branches/nota-show-app/src/ts7200/test_client.c b/branches/nota-show-app/src/ts7200/test_client.c
new file mode 100644 (file)
index 0000000..c5f1a4b
--- /dev/null
@@ -0,0 +1,54 @@
+#ifndef NOTAIO_H
+#define NOTAIO_H
+
+#include <stdio.h>
+#include <errno.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+#define USE_H_IN3      //h_in2 or h_in3
+
+#ifdef USE_H_IN3
+#include "nota3/h_in/h_bsdapi.h"
+#else
+#include "h_in.h"
+#endif
+
+#define SID 1
+#define DEFAULT_PORT 0
+
+int main()
+{
+    int sock, err;
+    char buf;
+    nota_addr_t addr = { SID, DEFAULT_PORT };
+    sock = Hsocket( Hgetinstance(), AF_NOTA, SOCK_STREAM, 0 );
+    if(sock < 0)
+    {
+        perror( "Hsocket" );
+        exit( 1 );
+    }
+
+    err = Hconnect( Hgetinstance(), sock, (struct sockaddr*) &addr, sizeof(addr) );
+    if( err != 0 ) 
+    {
+        Hclose( Hgetinstance(), sock );
+        perror( "Hconnect" );
+        exit( 1 );
+    }
+
+    buf = 'a';
+    err = Hsend( Hgetinstance(), sock, &buf, 1, 0 );
+    if(err != 1) {
+        Hclose( Hgetinstance(), sock );
+        perror( "Hsend" );
+        exit( 1 );
+    }
+
+    printf( "Wyslano %d znakow: %c\n", err, buf );
+    Hclose( Hgetinstance(), sock );
+
+    return 0;
+}
+
+#endif