Skip to content

Commit

Permalink
TCP server client basic framework
Browse files Browse the repository at this point in the history
  • Loading branch information
Max-X2 committed Oct 11, 2018
1 parent bc5a898 commit 3948868
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
11 changes: 11 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package main

import (
"fmt"
"net"
)

func main() {
conn, _ := net.Dial("tcp", "127.0.0.1:8080")
fmt.Fprintf(conn, "testing spaces\n")
}
19 changes: 19 additions & 0 deletions server.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package main

import (
"fmt"
"net"
)

func main() {
ln, _ := net.Listen("tcp", ":8080")
for {
// Grab connection
conn, _ := ln.Accept()
var msg []byte

// Reads from connection and stores in msg
fmt.Fscan(conn, &msg)
fmt.Println("Message:", string(msg))
}
}

0 comments on commit 3948868

Please sign in to comment.