Reference Home

Get Response

Description

When remote server replay to a request sent by Arduino, a getResponse function in Arduino loop can manage data sent from server.

 

This function store data in a fixed buffer : linebuff of LINEBUFFLEN size.

If data exceed are cut.

Syntax

HTTP.getResponse(int socket)

Parameters

socket : link socket

Returns

pointer to linebuff string

or NULL if no response is came

 

This function store data in a user buffer. So, it allows to receive more bytes expecially using function getNextResponseBuffer() in a loop until it returns 0.

Syntax

HTTP.getResponse(int socket,byte rbuff,int rbufflen) //first response

HTTP.getNextResponseBuffer(int socket,byte rbuff,int rbufflen) //following reading

Parameters

socket : link socket

rbuff: buffer to receive response

rbufflen: buffer length

Returns

number of bytes really read (if 0 no more bytes availlable)

Syntax

HTTP.getResponseMessage() //returns HTTP code

Parameters

nothing

Returns

HTTP code as null terminated string

Example:

#include <HTTPlib.h> //library include

 

HTTP WIFI; //instance of HTTP (inherits any stuff of MWiFi)

:

:

void loop{

:

:

char *line=getResponse(csocket);

if (line!=NULL) Serial.print(line):

:

}

or

int rsp=getResponse(csocket,buff,64);

while(rsp>0)

{

rsp=getNextResponseBuffer(csocket,buff,64);

:

}

:

}

 

 

Reference Home