added door daemon go
authorOthmar Gsenger <otti@realraum.at>
Thu, 7 Mar 2013 21:39:08 +0000 (21:39 +0000)
committerOthmar Gsenger <otti@realraum.at>
Thu, 7 Mar 2013 21:39:08 +0000 (21:39 +0000)
fixed type plakat

door_daemon_go/run.sh [new file with mode: 0755]
door_daemon_go/unix_socket_server.go [new file with mode: 0644]
logo/plakat.svg

diff --git a/door_daemon_go/run.sh b/door_daemon_go/run.sh
new file mode 100755 (executable)
index 0000000..8f8d5bd
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+clear
+rm /tmp/test.sock
+go build unix_socket_server.go && ./unix_socket_server || sleep 5
diff --git a/door_daemon_go/unix_socket_server.go b/door_daemon_go/unix_socket_server.go
new file mode 100644 (file)
index 0000000..aca60b8
--- /dev/null
@@ -0,0 +1,66 @@
+package main
+import "fmt"
+import "net"
+import "bufio"
+
+func handleConnection(c net.Conn) () {
+    fmt.Println("new connection")
+    var client *bufio.ReadWriter;
+    {
+      client_r := bufio.NewReaderSize(c,14)
+      client_w := bufio.NewWriterSize(c,14)
+      client = bufio.NewReadWriter(client_r,client_w)
+    }
+    for {
+          wasPrefix:=false
+          var line string
+          for isPrefix:=true;isPrefix; {
+            var lineBuf []byte 
+            var err error
+            lineBuf,isPrefix,err = client.ReadLine()
+            if err != nil {
+                fmt.Printf("Readline Error: %s\n",err.Error())
+                c.Close()
+                return
+            }
+            if isPrefix {
+              wasPrefix=true
+            } else {
+              line=string(lineBuf)
+            }
+          }
+          if wasPrefix {
+              fmt.Println("line too long")
+              fmt.Fprintf(client,"line too long\n")
+              client.Flush()
+              continue
+          }
+          fmt.Printf("Received: %v\n", string(line))
+//
+//        data := buf[0:nr]
+//        fmt.Printf("Received: %v", string(data))
+//        _, err = c.Write(data)
+//        if err != nil {
+//            fmt.Println("Write: " + err.Error())
+//            return
+//        }
+    }
+}
+
+
+func main() {
+  ln, err := net.Listen("unix", "/tmp/test.sock")
+  if err != nil {
+    fmt.Printf("Error: %s\n",err.Error())
+    return
+  }
+  fmt.Printf("Listener started\n")
+  for {
+    conn, err := ln.Accept()
+    if err != nil {
+      // handle error
+      continue
+    }
+    go handleConnection(conn)
+  }
+}
index 0826573..1f3c0a4 100644 (file)
@@ -46,9 +46,9 @@
      id="namedview2820"
      showgrid="false"
      units="mm"
-     inkscape:window-width="1920"
-     inkscape:window-height="1141"
-     inkscape:window-x="1024"
+     inkscape:window-width="1400"
+     inkscape:window-height="995"
+     inkscape:window-x="0"
      inkscape:window-y="27"
      inkscape:window-maximized="1" />
   <metadata
    style="font-weight:bold;-inkscape-font-specification:Sans Bold"
    id="tspan3100">Vorträge</tspan> und <tspan
    style="font-weight:bold;-inkscape-font-specification:Sans Bold"
-   id="tspan3102">Workshops</tspan> zu veranstalten. So etwas nennst sich <tspan
+   id="tspan3102">Workshops</tspan> zu veranstalten. So etwas nennt sich <tspan
    style="font-weight:bold;-inkscape-font-specification:Sans Bold"
    id="tspan3104">Hackerspace</tspan>.</tspan><tspan
          sodipodi:role="line"