Unix.icl 536 Bytes
Newer Older
Mart Lubbers's avatar
Mart Lubbers committed
1 2 3 4
implementation module System.Socket.Unix

import StdEnv
import Data.Error
Mart Lubbers's avatar
Mart Lubbers committed
5
import System.FilePath
Mart Lubbers's avatar
Mart Lubbers committed
6 7
import System.Socket
import System._Pointer
Mart Lubbers's avatar
Mart Lubbers committed
8
from System._Socket import AF_UNIX
Mart Lubbers's avatar
Mart Lubbers committed
9

Mart Lubbers's avatar
Mart Lubbers committed
10
instance SocketAddress UnixSocketAddress where
Mart Lubbers's avatar
Mart Lubbers committed
11
	sa_serialize sa p w
Camil Staps's avatar
Camil Staps committed
12 13 14
		# p = writeInt2 p 0 (sa_domain sa)
		# p = writeCharArray (p+2) (packString sa.sun_path)
		= (p, w)
Mart Lubbers's avatar
Mart Lubbers committed
15 16 17 18
	sa_deserialize p
		= Ok {sun_path=derefString (p+2)}
	sa_length _ = 110
	sa_domain _ = AF_UNIX
Mart Lubbers's avatar
Mart Lubbers committed
19
	sa_null = {sun_path="/"}
Mart Lubbers's avatar
Mart Lubbers committed
20

Mart Lubbers's avatar
Mart Lubbers committed
21
instance toString UnixSocketAddress where toString s = s.sun_path