Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: ResolveTCPAddr cannot parse literal tcp endpoint on non-tcp network #8981

Closed
gopherbot opened this issue Oct 22, 2014 · 2 comments
Closed

Comments

@gopherbot
Copy link

by mathias.dietrich:

go version go1.3.3 darwin/amd64


/* DaytimeServer
 */
package main

import (
    "fmt"
    "net"
    "os"
    "time"
)

func main() {

    service := ":1200"
    tcpAddr, err := net.ResolveTCPAddr("ip4", service)
    checkError(err)

    listener, err := net.ListenTCP("tcp", tcpAddr)
    checkError(err)

    for {
        conn, err := listener.Accept()
        if err != nil {
            continue
        }

        daytime := time.Now().String()
        conn.Write([]byte(daytime)) // don't care about return value
        conn.Close()                // we're finished with this client
    }
}

func checkError(err error) {
    if err != nil {
        fmt.Fprintf(os.Stderr, "Fatal error: %s", err.Error())
        os.Exit(1)
    }
}
@gopherbot
Copy link
Author

Comment 1 by mathias.dietrich:

tcpAddr, err := net.ResolveTCPAddr("ip4", service)  
should be:
tcpAddr, err := net.ResolveTCPAddr("tcp4", service)
not an go issue, please close CR

@davecheney
Copy link
Contributor

Comment 2:

Status changed to Retracted.

@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants