changeset 139:9bce890a7ff2

Old work on a socket module
author Mike Pavone <pavone@retrodev.com>
date Fri, 09 Aug 2013 01:32:35 -0700
parents 966a09d226e3
children bf8f75b69048
files modules/socket.tp
diffstat 1 files changed, 67 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/socket.tp	Fri Aug 09 01:32:35 2013 -0700
@@ -0,0 +1,67 @@
+#{
+	llMessage: AF_INET withVars: {
+		intret <- obj_int32 ptr
+	} andCode: {
+		intret <- make_object: (addr_of: obj_int32_meta) NULL 0
+		intret num!: AF_INET
+		intret
+	}
+	llMessage: AF_UNIX withVars: {
+		intret <- obj_int32 ptr
+	} andCode: {
+		intret <- make_object: (addr_of: obj_int32_meta) NULL 0
+		intret num!: AF_UNIX
+		intret
+	}
+	llMessage: STREAM withVars: {
+		intret <- obj_int32 ptr
+	} andCode: {
+		intret <- make_object: (addr_of: obj_int32_meta) NULL 0
+		intret num!: SOCK_STREAM
+		intret
+	}
+	llMessage: DGRAM withVars: {
+		intret <- obj_int32 ptr
+	} andCode: {
+		intret <- make_object: (addr_of: obj_int32_meta) NULL 0
+		intret num!: SOCK_DGRAM
+		intret
+	}
+	llMessage: socket withVars: {
+		fd <- obj_int32 ptr
+		domain <- obj_int32 ptr
+		type <- obj_int32 ptr
+		protocol <- obj_int32 ptr
+	} andCode: :domain type protocol {
+		fd <- make_object: (addr_of: obj_int32_meta) NULL 0
+		fd num!: (socket: (domain num) (type num) (protocol num))
+		fd
+	}
+	
+	llMessage: getaddrinfo withVars: {
+		
+	} andCode: {
+	}
+	
+	new <- :domain type protocol {
+		sfd <- socket: domain type protocol
+		#{
+			fd <- {sfd}
+			llMessage: close withVars: {
+				sfd <- obj_int32 ptr
+			} andCode: {
+				sfd <- mcall: fd 1 self
+				close: (sfd num)
+				self
+			}
+		}
+	}
+	
+	connectTo:onPort <- :host :port {
+		
+	}
+	listenOn: <- :port {
+	}
+	listenAt:onPort <- :host :port {
+	}
+}