started adding a socket module and the Socket class
This commit is contained in:
48
moo/kernel/Socket.moo
Normal file
48
moo/kernel/Socket.moo
Normal file
@ -0,0 +1,48 @@
|
||||
class Socket(Object) from 'sck'
|
||||
{
|
||||
var handle := -1.
|
||||
|
||||
method(#primitive) _open(domain, type, proto).
|
||||
method(#primitive) _connect(a,b,c).
|
||||
method(#primitive) _close.
|
||||
}
|
||||
|
||||
(* TODO: generate these domain and type from the C header *)
|
||||
pooldic Socket.Domain
|
||||
{
|
||||
INET := 2.
|
||||
INET6 := 10.
|
||||
}
|
||||
|
||||
pooldic Socket.Type
|
||||
{
|
||||
STREAM := 1.
|
||||
DGRAM := 2.
|
||||
}
|
||||
|
||||
extend Socket
|
||||
{
|
||||
method(#class) domain: domain type: type
|
||||
{
|
||||
^super new _open(domain, type, 0).
|
||||
}
|
||||
|
||||
method beginConnect
|
||||
{
|
||||
(*
|
||||
| s1 s1 |
|
||||
s1 = Semaphore new.
|
||||
s2 = Semaphore new.
|
||||
|
||||
s1 signalHandler: [xxxxx].
|
||||
s2 signalHandler: [xxxxxx].
|
||||
|
||||
fcntl (nonblock);
|
||||
|
||||
Processor signal: s1 onOutput: self.handle.
|
||||
Processor signal: s2 after: timeout.
|
||||
|
||||
connect ();
|
||||
*)
|
||||
}
|
||||
}
|
@ -15,6 +15,7 @@ class MyObject(Object)
|
||||
'internal error that should never have happened'
|
||||
'insufficient system memory'
|
||||
'insufficient object memory'
|
||||
'invalid class/type'
|
||||
|
||||
'invalid parameter or argument'
|
||||
'data not found'
|
||||
|
Reference in New Issue
Block a user