Usermode/libc - Fix strchr and strrchr behavior
[tpg/acess2.git] / Tools / NetTest / tcpclient.c
1 /*
2  * Acess2 Networking Test Suite (NetTest)
3  * - By John Hodge (thePowersGang)
4  *
5  * tcpclient.c
6  * - TCP Client tester
7  */
8 #include <vfs.h>
9 #include <vfs_ext.h>
10 #include <nettest.h>
11
12 void NetTest_Suite_Netcat(const char *Address, int Port)
13 {
14         Uint8   addr[16];
15         int type = Net_ParseAddress(Address, addr);
16         if( type == 0 )
17                 return;
18
19         int fd = Net_OpenSocket_TCPC(type, addr, Port);
20         if( fd == -1 ) {
21                 Log_Error("Netcat", "herpaderp tcpc");
22                 return ;
23         }
24         Log_Notice("Netcat", "Connection open");
25
26         char    buffer[1024];
27         size_t  len;
28         while( (len = VFS_Read(fd, sizeof(buffer), buffer)) )
29         {
30                 NetTest_WriteStdout(buffer, len);
31         }
32         
33         Log_Notice("Netcat", "Closing connection");
34
35         VFS_Close(fd);
36 }

UCC git Repository :: git.ucc.asn.au