Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "net"
- )
- type Client struct {
- }
- func main() {
- fmt.Println("starting server")
- ln, err := net.Listen("tcp", "localhost:5000")
- if err != nil {
- fmt.Println("couldn't listen at the port")
- return
- }
- for {
- conn, err := ln.Accept()
- if err != nil {
- fmt.Println("couldn't accept the connection")
- return
- }
- b := make([]byte, 1024)
- n, err := conn.Read(b)
- if err != nil {
- fmt.Println("couldn't read the data")
- }
- fmt.Println(n)
- fmt.Println("received the message", string(b))
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement