Preparing all basic files

This commit is contained in:
raul 2024-03-11 08:43:14 +01:00
parent 6b540e88c0
commit fc50027b39
5 changed files with 57 additions and 0 deletions

5
client.go Normal file
View File

@ -0,0 +1,5 @@
package main
func client() {
}

3
go.mod Normal file
View File

@ -0,0 +1,3 @@
module battleship
go 1.22.1

9
main.go Normal file
View File

@ -0,0 +1,9 @@
package main
import (
"fmt"
)
func main() {
fmt.Println("Sample text")
}

24
server.go Normal file
View File

@ -0,0 +1,24 @@
package main
import (
"fmt"
"net"
)
func server() {
}
func getIP(conn net.Conn) (address *net.TCPAddr) {
if addr, ok := conn.RemoteAddr().(*net.TCPAddr); ok {
return addr
//fmt.Printf("Received connection from: %v\n", addr)
}
return
}
func handleConn(conn net.Conn) {
fmt.Println()
address := getIP(conn)
fmt.Printf("%v connected!\n", address)
}

16
tools.go Normal file
View File

@ -0,0 +1,16 @@
package main
import (
"fmt"
"os"
)
func catchErr(err error) (errHappened bool) {
errHappened = false
if err != nil {
errHappened = true
fmt.Println(err)
os.Exit(2)
}
return errHappened
}