(cleanup)

master
Jordan Orelli 12 years ago
parent 10c674b7f3
commit 55e08628c0

@ -7,11 +7,12 @@ import (
"os"
)
var tcpAddr = flag.String("tcp", "", "foo")
var (
tcpAddr = flag.String("tcp", "", "tcp ip:port to listen on")
)
func runfile() {
filename := flag.Args()[0]
fmt.Println(filename)
f, err := os.Open(filename)
if err != nil {
fmt.Fprintln(os.Stderr, "unable to read file ", filename)

@ -73,10 +73,16 @@ func (i interpreter) send() {
for {
select {
case v := <-i.values:
if i.out1 == nil {
return
}
if _, err := fmt.Fprintln(i.out1, v); err != nil {
fmt.Println("can't write out to client: ", err)
}
case e := <-i.errors:
if i.out2 == nil {
return
}
if _, err := fmt.Fprintln(i.out2, e); err != nil {
fmt.Println("can't write error to client: ", err)
}

@ -204,7 +204,6 @@ func main() {
}
if *tcpAddr != "" {
runTCPServer()
return
}
if len(flag.Args()) > 0 {
runfile()

@ -24,11 +24,11 @@ func runTCPServer() {
printErrorMsg(err.Error())
continue
}
go startConnection(conn, manager)
go startTCPConnection(conn, manager)
}
}
func startConnection(conn net.Conn, m *cm.Manager) {
func startTCPConnection(conn net.Conn, m *cm.Manager) {
m.Add(conn)
defer m.Remove(conn)

Loading…
Cancel
Save