started adding a socket module and the Socket class

This commit is contained in:
hyunghwan.chung
2017-10-18 16:15:51 +00:00
parent 016b7c2dac
commit 2c85319cb0
21 changed files with 546 additions and 104 deletions

48
moo/kernel/Socket.moo Normal file
View 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 ();
*)
}
}

View File

@ -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'