Wednesday 6 June 2012

How to send HTTP request


#define __INFINITE__ 0x00FFFFFF
#define __20_SECONDS__ 2000
#define __100_MSECONDS__ 10
static int PerformTestTCP_HTTP( char *szHostname, int nPort )
{
int nHandle = 0;
int nResult = 0;
int nReceived = 0;
int nTotalReceived = 0;
unsigned char pucData[64];
//
// Connect to IP Test server.
//
nResult = tcp_connect_to_server( szHostname, nPort, __20_SECONDS__ );
if( nResult >= 0 )
{
nHandle = nResult;
//
// Send HTTP request.
//
while(( nResult = tcp_send_to_server( nHandle,
"GET / HTTP/1.0\r\n\r\n", 18,
__INFINITE__ ))
== ERROR_TIMEOUT )
{
ttestall( 0, __100_MSECONDS__ );
}
if( nResult == 18 )
{
//
// HTTP request sent.
// Infinite Wait (the HTTP disconnection will be performed
// by the remote server.
//
while(( nResult = tcp_recv_from_server( nHandle,
pucData, 64,
__20_SECONDS__ )) > 0 )
{
nReceived = nResult;
nTotalReceived += nReceived;
}
}
// Disconnect and release the allocated handle.
tcp_disconnect_from_server( nHandle );
}
else
{
// Error during connection.
}
return nResult;

9 comments:

  1. Hi,
    I am a new to Ingenico. I am working currently on EFT930M device. I have to implement the smart card reader in C. The SDK for the device contains a few sample code in C but it does not contain anything about the smart card reader. It would be kind of you if you could share some sample code for the same or any details that would be helpfull.

    Thanks
    Parag

    ReplyDelete
  2. hi,
    sorry for late reply..
    you can try the sample code provided in the following directory..
    Program Files\SDK30\SDK 9.4.0\SDK\Samples
    and also contact to ingenico training center

    ReplyDelete
    Replies
    1. hello, can you provide the latest version of the Telium SDK or at least that mentioned in your comment ?

      Delete
  3. hi, can u help me out with the http request.... if i want to hit a webpage with my app, what shud be the request

    ReplyDelete
  4. hi,
    in above posted code-
    method tcp_connect_to_server(szHostname, nPort, __20_SECONDS__);
    perform the connection to the server.

    szHostname: address of the server to which you want to connect
    tcp_port : TCP server port.(Ex:80)
    timeout : Timeout connection in 20 seconds.

    another important method is:
    nResult = tcp_send_to_server(nHandle, url, strlen(url), time_out);

    which takes your http request and get the return responce to nResult variable.

    url:'GET /server_ip/requested_page.html HTTP/1.0\r\n\r\n'

    ReplyDelete
  5. Hi,
    Can u post some sample code for emv card transaction..

    ReplyDelete
  6. Dear Sir,

    Refer to subject, MA Technology Solution is specializing in providing end-to-end solution on Ingenico pos terminals.
    Please let us know, minhaj_akhter is Skype id. add and call,we will be happy to give you details.

    Looking forward to your early reply!


    Best regards,

    ReplyDelete
  7. Some body can help to get Telium 2 SDK ?
    Thanks in advance.

    ReplyDelete
  8. Hi, can you help out in implementing EMV for rupay cards with latest sdk from ingenico 9.24 ??currently working on iwb250 terminals and stuck in sample provided by ingenico in sdk package...seeking help ...please do guide

    thanks in advance

    ReplyDelete