From: Jean-Philippe Andriot <andriot@6WIND.com>
To: Ken Nagorski <rocket@refriedgeeks.com>
Cc: linux-c-programming@vger.kernel.org
Subject: Re: !! SPAM Suspect : SPAM-URL-DBL !! working with threads
Date: Thu, 02 Feb 2006 15:59:58 +0100 [thread overview]
Message-ID: <43E21E6E.4040007@6WIND.com> (raw)
In-Reply-To: <43E028A5.2040406@refriedgeeks.com>
Hi
I think your use of 'wait' is invalid here
JP
Ken Nagorski wrote:
> Hi there,
>
> I have created a small IM client that talks to an IM server that I wrote
> in java. It doesn't have a problem sending data however I am using a
> pthread to call a listener function. It works OK but when I click back
> on the program say to type some other text it just crashes. I have been
> teaching myself C but I am having a problem understanding how to pass
> control back to the main thread. That isn't a problem in java.
>
> forgive me if I am not even asking this right cause like I said. I am
> teaching this to myself as my school doesn't offer C.
>
> below is the code maybe someone will be able to point me in the right
> direction.
>
> how the thread is created.
> when the user clicks connect and if there is a successful sockfd
> created... I call this
> listner_thread_id = pthread_create( &listner_thread, NULL,
> message_listner, (void *)data_to_be_sent);
>
> The message listener function
> static void *message_listner(void *data)
> {
> struct Data_To_Be_Sent *data_to_be_sent;
> data_to_be_sent = (Data_To_Be_Sent*)data;
> gchar *text;
> gchar *carriage_return = "\n";
> GtkTextIter start, end;
> int numbytes, ix=1;
>
> g_print("I am waiting for incoming data...\n");
> while(1)
> {
> if((numbytes=recv(data_to_be_sent->sockfd,
> data_to_be_sent->buffer, 255, 0)) == -1)
> {
> printf("There was an error reciving data\n");
> exit(1);
> } else {
> printf(((char *)data_to_be_sent->buffer));
> printf("\n%i\n", ix);
> wait(2);
> }
> ix++;
> }
> }
>
> Any ideas where I am going wrong?
>
> Thanks
> ken
>
> -
> To unsubscribe from this list: send the line "unsubscribe
> linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
>
prev parent reply other threads:[~2006-02-02 14:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-01 3:19 working with threads Ken Nagorski
2006-02-02 14:59 ` Jean-Philippe Andriot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=43E21E6E.4040007@6WIND.com \
--to=andriot@6wind.com \
--cc=linux-c-programming@vger.kernel.org \
--cc=rocket@refriedgeeks.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).