On 2005-06-09 16:47:47 +0100 Thierry DELHAISE
<[EMAIL PROTECTED]> wrote:
Hi the list,
I'have to develop a daemon with quite complex task, so I think
gnustep-base
can help me realise this task.
I plan to use NSRunLoop and NSNotificationCenter. Others class too, but
regarding the subject of my mail , just those two will be mentionned ;-)
NSRunLoop accept "Input" for any subclass of NSPort. I've found
NSSocketPort
wich could make the job, but I think NSSocketPort is closed to DO and so
any
packets receive by a NSSocketPort will be interpret has a DO request by
the
way of NSConnection. Right or not on that ?
While NSPort is not completely tied to the DO system, it's not very useful
on its own ... so I don't think you would want to work with NSPort. You can
use an NSPort to send data to another NSPort and receive data from another
NSPort, but if that's what you want to do, you would be better advised to
use an NSConnection to send messages.
So I would like to develop a NSNetPort (allways based on socket) but wich
will deliver some Notifications when some input arrive. If I allready take
a
look on how to do that, I would like to know if the default behavior of a
NSPort subclass is not to make only DO. Since if I add my new NSNetPort to
the RunLoop, it will not try basicaly to process a DO request when it will
call my getFDS subclass method ?
Finaly, If it's not the right way to go, how can I do the job (allways by
using NSRunLoop and NSDefaultCenter) : what kind of class or subclass I
have
to provide ?
My guess is that you want to communicate over a TCP/IP connection with
another application which is not a GNUstep application (if it was a GNUstep
application you would use NSConnection).
The correct way to do this is with the NSFileHandle class.
You can create an NSFileHandle instance by passing it a socket file
descriptor, then use the NSFileHandle methods to read and write data either
synchronously or asynchronously. The asynchronous API will generate and
send an NSNotification when data is read or written.
Easier still, you can use GNUstep specific extensions to the NSFileHandle
API to create the socket connection.
If you want a realistic example (necessarily a little complex), look at
base/Source/GSFTPURLHandle.m ... it implements fetching a file via FTP,
which in turn requires a telnet protocol connection, which is done using the
asynchronous (notification based) NSFileHandle API.
_______________________________________________
Discuss-gnustep mailing list
Discuss-gnustep@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnustep