Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: gatlin/Saturn
base: a9e51aa66d
...
head fork: gatlin/Saturn
compare: a1df8d97ea
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Showing with 66 additions and 0 deletions.
  1. +2 −0  .gitignore
  2. +42 −0 src/saturn/main.go
  3. +22 −0 src/test2/test2.go
View
2  .gitignore
@@ -1 +1,3 @@
*.swp
+bin/*
+pkg/*
View
42 src/saturn/main.go
@@ -0,0 +1,42 @@
+package main
+
+import (
+ "fmt"
+ "net"
+ "minisat"
+)
+
+func main() {
+ /* listen on a port for incoming problems */
+ ln, err := net.Listen("tcp",":1888")
+ if err != nil {
+ fmt.Printf("ERROR on listen\n")
+ }
+
+ /* each request gets a goroutine */
+ for {
+ conn, err := ln.Accept()
+ if err != nil {
+ fmt.Printf("ERROR on accept")
+ }
+ go handleConnection(conn)
+ }
+}
+
+func handleConnection(c net.Conn) {
+ buffer := make([]byte,2048)
+
+ _, err := c.Read(buffer)
+ if err != nil {
+ fmt.Printf("ERROR on read\n")
+ }
+
+ solvable, _ := minisat.SolveDIMACS(string(buffer))
+ if solvable {
+ c.Write([]byte("Solvable"))
+ } else {
+ c.Write([]byte("Not solvable"))
+ }
+ c.Close()
+}
+
View
22 src/test2/test2.go
@@ -0,0 +1,22 @@
+package main
+
+import (
+ "fmt"
+ "net"
+ "bufio"
+)
+
+func main() {
+ conn,dialerr := net.Dial("tcp","localhost:1888")
+ if dialerr != nil {
+ fmt.Printf("well shit\n")
+ }
+ conn.Write([]byte("1 0\n-1 2 0\n2 0"))
+
+ response := make([]byte,2048)
+ _, reserr := bufio.NewReader(conn).Read(response)
+ if reserr != nil {
+ fmt.Printf("ERROR receiving response")
+ }
+ fmt.Printf("Response: %s\n",string(response))
+}

No commit comments for this range

Something went wrong with that request. Please try again.