Unix.icl 568 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
		# p = writeInt2 p 0 (sa_domain sa)
Mart Lubbers's avatar
Mart Lubbers committed
13
		# p = writeCharArray (p+2) (packString sa.unix_socket_path)
Camil Staps's avatar
Camil Staps committed
14
		= (p, w)
Mart Lubbers's avatar
Mart Lubbers committed
15
	sa_deserialize p
Mart Lubbers's avatar
Mart Lubbers committed
16
		= Ok {unix_socket_path=derefString (p+2)}
Mart Lubbers's avatar
Mart Lubbers committed
17 18
	sa_length _ = 110
	sa_domain _ = AF_UNIX
Mart Lubbers's avatar
Mart Lubbers committed
19
	sa_null = {unix_socket_path="/"}
Mart Lubbers's avatar
Mart Lubbers committed
20

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