9 years, 6 months ago.

http post issue

Hi all, I am trying to post data to trigger my device, I observed when i trigger it by putting the ip of my device in http.post(ip,map,&intext) it works fine, it triggers my device.

But when i put this code into my application (which received udp broadcast msg) it doesnt do any thing, weird thing is that my entire application gets stuck and it doesnt execute single line of code, even it doesnt get the ip from dhcp.

when i comment the line http.post(ip,map,&intext), application works fine then, issue what i think is that mbed is not allowing two sockets in a single application (one udp and one http).

can any one help me on this ?? below is my chunk of code

  EthernetInterface eth;
   eth.init(); //Use DHCP
    eth.connect();
  
  
    printf("IP Address is %s\n", eth.getIPAddress());
    UDPSocket socket;
    socket.bind(BROADCAST_PORT);
    socket.set_broadcasting();

 Endpoint broadcaster;
    char buffer[256];
    
   

    Endpoint echo_server;
    while (1) {
       printf("\nWait for packet...\n");
       int n = socket.receiveFrom(broadcaster, buffer, sizeof(buffer));
       buffer[n] = '\0';
         printf("n is %d \n",n);
        printf("Packet from \"%s\": %s\n", broadcaster.get_address(), buffer);

  HTTPMap map;
    HTTPText inText(str, 512);
    map.put("Hello", "World");
    map.put("test", "1234");
    printf("\nTrying to post data...\n");
 

        
  // http.post("ip/cgi-bin/exte=0", map, &inText); //line 58
//some more code
}}}}}

so if i comment line 58 app runs fine, but when i uncomment this line to post mt data it doest even take the ip

done with it, i just fixed the issue, it was port issue, webserver is running on port 80 plus http post was also using the port 80 as well. i changed the port number to 443 in one of the library and it fixed the issue

posted by zain aftab 08 Nov 2014
Be the first to answer this question.