RE: failure when running from other thread.(SOUP_STATUS_CANT_CONNECT) Demo source



-----Oorspronkelijk bericht-----
Van: Dan Winship [mailto:danw gnome org] 
Verzonden: dinsdag 24 januari 2012 17:37
Aan: Sagaert Johan
CC: libsoup-list gnome org
Onderwerp: Re: failure when running from other thread.(SOUP_STATUS_CANT_CONNECT)

On 01/24/2012 08:08 AM, Sagaert Johan wrote:
> Here is my code :

can you include the non-working version as well?

-- Dan

I will try to use some other toolchain combination to see if it has any influence.

uclibc 0.9.32.1 binutils gcc 4.5.3 libsoup 2.32.2 or 2.35.92 libglib2.28.8

# ./SoupSMSTest
starting...
Running from thread
SUPPORTED 1
get request done Cannot connect to destination (api.clickatell.com) 4
status returned=4
body returned=(null)
header returned=0x1b590
#


# ./SoupSMSTest
starting...
Running from main
SUPPORTED 1
get request done Accepted 202
status returned=202
body returned=<?xml version="1.0"?>
<clickAPI>
        <sendMsgResp>
                <apiMsgId>e5b99ac46cb6c3e040b51eb0a25c5933</apiMsgId>
                <sequence_no></sequence_no>
        </sendMsgResp>
</clickAPI>

header returned=0x19590
#

//////////////////////////////////////////////////////
/*
 * main.c
 *
 *  Created on: jan 24, 2012
 *      Author: Johan
 */

#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include <libsoup/soup.h>


void soaptest(void)
{
	SoupMessage *msg;
	SoupSession *session=NULL;
	guint status;
	char encoded[1024] ;

	g_thread_init (NULL);
	g_type_init ();

	printf("SUPPORTED %i\n",g_thread_supported ());

	session=soup_session_sync_new();
	if (session==NULL)
	{
		printf("Could not soup_session_sync_new\n");
		return;
	}

	char
request[]="<clickAPI><sendMsg><api_id>3179973</api_id><user>zzzzzz</user><password>xxxxxxx</password><to>32479504265</to><text>testm
et Veel__spatieoverxml</text><from>ApexSyst</from></sendMsg></clickAPI>";
	char * uriencoded=soup_uri_encode(request,NULL);
	sprintf(encoded,"http://api.clickatell.com/xml/xml?data=%s",uriencoded);
	msg = soup_message_new ("GET",encoded);

	status = soup_session_send_message (session, msg);

	printf("get request done %s %i\n",msg->reason_phrase,msg->status_code);
	printf("status returned=%i\n",status);
	printf("body returned=%s\n",msg->response_body->data);
	printf("header returned=%p\n",msg->response_headers);

	soup_message_finished(msg);
	free(uriencoded);
}

void *mythread_function( void *ptr )
{
	soaptest();
	return NULL;
}

//#define RUNFROMMAIN
int main (void)
{
	printf("starting...\n");


#ifdef RUNFROMMAIN
	printf("Running from main\n");
	soaptest();
#else
	printf("Running from thread\n");
	pthread_t thread_id;
	pthread_create( &thread_id, NULL, mythread_function, NULL );
	pthread_join( thread_id, NULL);
#endif

	return 0;
}





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]