Welcome, Guest. Please login or register.

Author Topic: WaitSelect() with Reaction  (Read 1612 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline jahcTopic starter

  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 521
    • Show only replies by jahc
    • http://wookiechat.amigarevolution.com
WaitSelect() with Reaction
« on: September 20, 2003, 01:57:10 PM »
Heres a message I just posted to the amiga-c mailing list.. hopefully someone here might be able to help me, if the people on the amiga-c ml arent able to...

Quote

> On Mon, 24 Mar 2003, jahc2 wrote:
>
> > I'm having trouble using multiple tasks/processes and msgports,
so
> > now I'm looking into just using one task to handle every thing.
I'm
> > making an internet program with a MUI GUI. How can I make my
program
> > wait until there's information waiting at my socket? I'm thinking
> > WaitSelect() could possibly do the job? I want to wait for
internet
> > activity AND gui stuff at the same time, if thats possible.
>
> Correct, just use WaitSelect() instead of Wait() there... Also
remember
> use sockets in the non-blocking mode. Otherwise your UI gets stuck
very
> easily when sending/receiving data.


I'm using a Reaction GUI in my program now, and it wont process GUI  stuff until data arrives at my socket..

GetAttr(WINDOW_SigMask, window_obj, &signal);

WaitSelect(STDIN, &readfds, NULL, NULL, &tv, &signal);

I dont think "signal" is being signalled when I try to use my GUI. Does anyone here have any Reaction experience?
 

Offline PiR

  • Full Member
  • ***
  • Join Date: Apr 2003
  • Posts: 148
    • Show only replies by PiR
Re: WaitSelect() with Reaction
« Reply #1 on: September 23, 2003, 02:47:49 PM »
Hi

It was not so easy, but I've found it for you!
According to this thread, the Rogue's answer, socket notification is also done with task signals, so I think that you should give a long vacation to WaitSelect(), check the signal number of the socket, create a mask with all signals you need, and give a chance to Wait()...

The other solution could be two tasks - one for socket, the other for GUI. But you'll have to make yourself a possibility to wake up the task waiting on socket somehow, at least to have the ability to close it, while the is no activity on socket.

But to be honest - I have NULL Reaction experience.

Good luck
 

Offline PiR

  • Full Member
  • ***
  • Join Date: Apr 2003
  • Posts: 148
    • Show only replies by PiR
Re: WaitSelect() with Reaction
« Reply #2 on: September 26, 2003, 11:50:02 AM »
Hi again.

I did downoad AmiTCP_SDK just to look at it.
Ok, there is no way to find this signal out of the socket.

According to this thread, what Karlos is saying is that Reaction does some stuff in input.device task, which may mean even not signalling your task. Check it with some gadgets that HAVE TO be propagated to your task, like CloseWindow.

If this is case, then I think you'll have to make your own additional signalling.

Good luck
 

Offline xeron

  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 2533
    • Show only replies by xeron
    • http://www.petergordon.org.uk
Re: WaitSelect() with Reaction
« Reply #3 on: September 26, 2003, 12:02:47 PM »
Personally, I try to stay away from the WaitSelect() method. Instead I set up a socket event mask with SocketBaseTags, and use asynchrous non-blocking sockets. That way you can just use Wait( signal_mask | reaction_mask | whatever_mask ), and then see what needs attention.
Playstation Network ID: xeron6
 

Offline jahcTopic starter

  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 521
    • Show only replies by jahc
    • http://wookiechat.amigarevolution.com
Re: WaitSelect() with Reaction
« Reply #4 on: October 16, 2003, 06:35:22 AM »
How do you setup a socket event mask with SocketBaseTags() ? I'm reading the autodoc but I cant work it out.. sorry!

That sounds like a good way to do it though. Nice and simple to program.

Thanks everyone for your help so far..
 

Offline xeron

  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 2533
    • Show only replies by xeron
    • http://www.petergordon.org.uk
Re: WaitSelect() with Reaction
« Reply #5 on: October 16, 2003, 09:50:50 AM »
e-mail me at "pete at petergordon dot org dot uk" and i'll knock up a simple example and email it in a reply. I can't help right now because I'm at work...
Playstation Network ID: xeron6
 

Offline jahcTopic starter

  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 521
    • Show only replies by jahc
    • http://wookiechat.amigarevolution.com
Re: WaitSelect() with Reaction
« Reply #6 on: November 17, 2003, 03:10:31 AM »
Thanks for your help by email xeron..

My program works well now on my comupter, BUT it wont run on my friends computer.. It looks like the signal isnt getting through somehow..

if( ( socksigbit = AllocSignal( -1 ) ) == - 1 )
{
   printf( "Unable to allocate a signal\n" );
   return FALSE;
}
socket_signal = 1 << socksigbit;

Should the above line be 1L instead of just 1? Does it make a difference?