Golang net.ListenIP() function example
package net
Golang net.ListenIP() function usage example
package main
import (
"fmt"
"net"
"os"
)
func main() {
service := "127.0.0.1:8888"
IPAddr, err := net.ResolveIPAddr("ip4", service)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
IPconn, err := net.ListenIP("ip:tcp", IPAddr)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
for {
// listen2Client function will listen forever until terminate
// up to you to define how listen2Client works...
listen2Client(IPconn)
}
}
Advertisement
Something interesting
Tutorials
+15k Golang : Search folders for file recursively with wildcard support
+5.3k Golang : Generate Interleaved 2 inch by 5 inch barcode
+5.6k Fix fatal error: evacuation not done in time problem
+23.9k Golang : Fix type interface{} has no field or no methods and type assertions example
+10k Golang : Channels and buffered channels examples
+5.2k Golang : Experimental Jawi programming language
+20.2k Golang : Reset or rewind io.Reader or io.Writer
+11.4k Golang : Concatenate (combine) buffer data example
+22.9k Golang : Gorilla mux routing example
+21.3k Golang : Create and resolve(read) symbolic links
+12.4k Golang : Encrypt and decrypt data with x509 crypto
+22.9k Golang : Calculate time different