// Port gets the (remote) port of the client making the request.
552112
func (r *Request) Port() string {
	if r.port != "" {
		return r.port
	}

	_, port, err := net.SplitHostPort(r.W.RemoteAddr().String())
	if err != nil {
		r.port = "0"
		return r.port
	}

	r.port = port
	return r.port
}
1287820
func (s *SiteInfo) ServerPort() int {
	ps := s.s.PathSpec.BaseURL.URL().Port()
	if ps == "" {
		return 0
	}
	p, err := strconv.Atoi(ps)
	if err != nil {
		return 0
	}
	return p
}
924398
func (f *Request) Send() (*http.Response, error) {
	c := *http.DefaultClient
	if f.timeout != 0 {
		nc := f.newClient()
		c = *nc
	}

	if f.proxy != "" {
		proxyUrl, err := url.Parse(f.proxy)

		if err != nil {
			return nil, err
		}

		c.Transport = &http.Transport{
			Proxy: http.ProxyURL(proxyUrl),
		}
	}

	res, err := f.do(&c)
	return res, err
}
184142
func (a *NetAddr) Port(defaultPort int) int {
	_, port, err := net.SplitHostPort(a.Addr)
	if err != nil {
		return defaultPort
	}
	porti, err := strconv.Atoi(port)
	if err != nil {
		return defaultPort
	}
	return porti
}
251996
func OpenPort(c *Config) (*Port, error) {
	size, par, stop := c.Size, c.Parity, c.StopBits
	if size == 0 {
		size = DefaultSize
	}
	if par == 0 {
		par = ParityNone
	}
	if stop == 0 {
		stop = Stop1
	}
	return openPort(c.Name, c.Baud, size, par, stop, c.ReadTimeout)
}
292874
func splitPort(port string) (local, remote string) {
	parts := strings.Split(port, ":")
	if len(parts) == 2 {
		return parts[0], parts[1]
	}

	return parts[0], parts[0]
}
1247927
func Port(address string) (uint, error) {
	parts := strings.Split(address, ":")

	length := len(parts)
	if length < 2 {
		return 0, errors.New("Could not parse the port: malformated address")
	}

	port, err := strconv.Atoi(parts[length-1])
	if err != nil {
		return 0, err
	}
	if port < 0 {
		return 0, errors.New("Invalid port number")
	}

	return uint(port), nil
}
286114
func (a *Addr) HostPort(defaultPort int) string {
	port := a.Port
	if port == 0 {
		port = defaultPort
	}
	return net.JoinHostPort(a.Host, strconv.Itoa(port))
}
647007
func (self *HerokuDeploy) Port() int {
	p := os.Getenv("PORT")
	if p == "" {
		panic("PORT not defined")
	}
	i, err := strconv.Atoi(p)
	if err != nil {
		panic(err)
	}
	return i
}
143325
func (s *OptionConfiguration) SetPort(v int64) *OptionConfiguration {
	s.Port = &v
	return s
}
170745
func (ns Networks) Port(label string) (string, int) {
	for _, n := range ns {
		for _, p := range n.ReservedPorts {
			if p.Label == label {
				return n.IP, p.Value
			}
		}
		for _, p := range n.DynamicPorts {
			if p.Label == label {
				return n.IP, p.Value
			}
		}
	}
	return "", 0
}
270614
func (m *MCP23017Driver) getPort(portStr string) (selectedPort port) {
	portStr = strings.ToUpper(portStr)
	switch {
	case portStr == "A":
		return getBank(m.MCPConf.Bank).PortA
	case portStr == "B":
		return getBank(m.MCPConf.Bank).PortB
	default:
		return getBank(m.MCPConf.Bank).PortA
	}
}
534734
func (s *CreateDBInstanceInput) SetPort(v int64) *CreateDBInstanceInput {
	s.Port = &v
	return s
}
756578
func reqClient(port int) {
	sock, e := req.NewSocket()
	if e != nil {
		die("cannot make req socket: %v", e)
	}
	sock.AddTransport(ws.NewTransport())
	url := fmt.Sprintf("ws://127.0.0.1:%d/req", port)
	if e = sock.Dial(url); e != nil {
		die("cannot dial req url: %v", e)
	}
	// Time for TCP connection set up
	time.Sleep(time.Millisecond * 10)
	if e = sock.Send([]byte("Hello")); e != nil {
		die("Cannot send req: %v", e)
	}
	if m, e := sock.Recv(); e != nil {
		die("Cannot recv reply: %v", e)
	} else {
		fmt.Printf("%s\n", string(m))
	}
}
649778
func (s *GameSessionPlacement) SetPort(v int64) *GameSessionPlacement {
	s.Port = &v
	return s
}
821906
func (c *Tethering) Bind(port int) (*gcdmessage.ChromeResponse, error) {
	var v TetheringBindParams
	v.Port = port
	return c.BindWithParams(&v)
}
768330
func (c *Client) Connect(host string, port uint) (err error) {
	return c.dial(`tcp`, fmt.Sprintf(`%s:%d`, host, port))
}