Main Page Data Structures File List Data Fields Globals Related Pages

# inet/httpget.cpp File Reference

`#include <conio.h>`
`#include <stdio.h>`
`#include <string.h>`
`#include <stdlib.h>`
`#include <assert.h>`
`#include "inet/httpget.h"`
`#include "inet/base64.h"`
`#include "inet/dns.h"`
`#include "inet/url.h"`
`#include "clib/rtos.h"`
`#include "clib/tcpip.h"`
`#include "mpbuf.h"`
`#include "misc.h"`
`#include "vs1001.h"`

Go to the source code of this file.

## Functions
char * | sockgets (char *s, int n, int sd)
| Gets a string from a socket.
int | sockputs (const char *s, int sd)
| Outputs a string to a socket.
unsigned | http_connect (const char *urlString, int *error)
| Connect to a HTTP server.
void | getMetaData (int sd)
void | http_get (const char *urlString)

## Function Documentation

void getMetaData | ( | int | sd | ) |

| Definition at line 182 of file httpget.cpp. References MSG_TIMEOUT, and recv().

unsigned http_connect | ( | const char * | urlString,
|  | int * | error
| ) |

  | Connect to a HTTP server. Parameters:
  urlString | server URL to connect to
  error | variable receving the error code
Returns: socket descriptor for the connection, or 0 if an error occured. Definition at line 108 of file httpget.cpp. References base64encode(), DEFAULT_HTTP_PORT, free_url(), gethostbyname(), URL::host, inet_addr(), parse_url(), URL::pass, URL::path, URL::port, sockputs(), tcp_connect(), and URL::user. Referenced by http_get().

void http_get | ( | const char * | urlString | ) |

| Definition at line 203 of file httpget.cpp. References BUF_Clear(), BUF_GetFreeBytes(), BUF_GetSize(), BUF_Lock(), BUF_Play(), BUF_SetThreshold(), BUF_Unlock(), closesocket(), http_connect(), IP_PROTOTCP_LEVEL, MSG_TIMEOUT, recv(), RTX_Sleep_Time(), setsockopt(), sockgets(), and TCP_DELAY_ACK.

char* sockgets | ( | char * | s,
|  | int | n,
|  | int | sd
| ) |

  | Gets a string from a socket. sockgets reads characters from a socket into the string s. The function stops reading when it reads either n-1 characters or a newline character whichever comes first. sockgets retains the newline character at the end of s. A null byte is appended to s to mark the end of the string. Bug: shouldn't that be "n>0" ?! Parameters:
  s | pointer to string
  n | maximum length of string
  sd | socket to read from
Returns: pointer to received string, or NULL if an error occured. Definition at line 49 of file httpget.cpp. References MSG_TIMEOUT, and recv(). Referenced by http_get().

int sockputs | ( | const char * | s,
|  | int | sd
| ) |

  | Outputs a string to a socket. fputs copies the null-terminated string s to the given output stream; it does not append a newline character and the terminating null character is not copied. Parameters:
  s | pointer to string
  sd | socket to write to
Returns: On successful completion, puts sockputs returns a nonnegative value. Otherwise, it returns a value of EOF Definition at line 82 of file httpget.cpp. References send(). Referenced by http_connect().