This commit is contained in:
tkarrass 2016-02-05 16:19:43 +01:00
parent fb77010302
commit e480ec2db4
3 changed files with 26 additions and 3 deletions

View File

@ -1,6 +1,7 @@
package cmd // code.bitsetter.de/fun/gosl/cmd package cmd // code.bitsetter.de/fun/gosl/cmd
import ( import (
"encoding/gob"
"fmt" "fmt"
"log" "log"
"net" "net"
@ -13,14 +14,22 @@ import (
var cmdServer = &cobra.Command{ var cmdServer = &cobra.Command{
Use: "server", Use: "server",
Short: "Runs Gosl as a server", Short: "Runs Gosl as a server",
Long: "Runs Gosl as a server", Long: `Runs Gosl as a server
[TODO:]
gosl.json for configuration (Port/Adress, Level)
`,
// Run: // Run:
} }
func handleConn(conn *net.TCPConn) { func handleConn(conn *net.TCPConn) {
log.Println("Got a connection!") log.Println("Got a connection from: ", conn.RemoteAddr().String())
conn.Close()
gobd := gob.NewDecoder(conn)
var h data.Handshake
gobd.Decode(&h)
log.Println(h)
conn.Close()
} }
func runServer(cmd *cobra.Command, args []string) { func runServer(cmd *cobra.Command, args []string) {

14
data/Network.go Normal file
View File

@ -0,0 +1,14 @@
package data // code.bitsetter.de/fun/gosl/data
import (
"strconv"
)
type Handshake struct {
Client int
Name string
}
func (h Handshake) String() string {
return (h.Name + ": " + strconv.Itoa(h.Client))
}

BIN
gosl

Binary file not shown.