aboutsummaryrefslogtreecommitdiffstats
path: root/server.go
diff options
context:
space:
mode:
Diffstat (limited to 'server.go')
-rw-r--r--server.go20
1 files changed, 18 insertions, 2 deletions
diff --git a/server.go b/server.go
index d7718a8a6..feaf61076 100644
--- a/server.go
+++ b/server.go
@@ -2,7 +2,8 @@ package main
import (
"container/list"
- "time"
+ "net"
+ "log"
)
var Db *LDBDatabase
@@ -36,12 +37,27 @@ func NewServer() (*Server, error) {
return server, nil
}
+func (s *Server) AddPeer(conn net.Conn) {
+ s.peers.PushBack(NewPeer(conn, s))
+}
+
// Start the server
func (s *Server) Start() {
// For now this function just blocks the main thread
+ ln, err := net.Listen("tcp", ":12345")
+ if err != nil {
+ log.Fatal(err)
+ }
+
go func() {
for {
- time.Sleep( time.Second )
+ conn, err := ln.Accept()
+ if err != nil {
+ log.Println(err)
+ continue
+ }
+
+ go s.AddPeer(conn)
}
}()
}