9 int OpenTCP(const char *AddressString, short PortNumber);
12 * \fn int main(int argc, char *argv[])
15 int main(int argc, char *argv[])
19 uint8_t data[4096]; // Packet Data
21 con = OpenTCP("10.0.2.2", 80);
23 fprintf(stderr, "Unable to open TCP client\n");
27 #define REQ_STR "GET / HTTP/1.1\r\n"\
29 "User-Agent: Acess2 TCP Test Client\r\n"\
32 write(con, sizeof(REQ_STR)-1, REQ_STR);
34 while( (len = read(con, 4095, data)) > 0 )
37 _SysDebug("%i bytes - %s", len, data);
45 * \brief Initialise a TCP connection to \a AddressString on port \a PortNumber
47 int OpenTCP(const char *AddressString, short PortNumber)
50 uint8_t addrBuffer[16];
53 addrType = Net_ParseAddress(AddressString, addrBuffer);
55 fprintf(stderr, "Unable to parse '%s' as an IP address\n", AddressString);
60 fd = Net_OpenSocket(addrType, addrBuffer, "tcpc");
63 fprintf(stderr, "Unable to open TCP Client\n");
67 // Set remote port and address
68 ioctl(fd, 5, &PortNumber);
69 ioctl(fd, 6, addrBuffer);
72 if( ioctl(fd, 7, NULL) == 0 ) {
73 fprintf(stderr, "Unable to start connection\n");
77 printf("Connection opened\n");