Skip to content

Commit

Permalink
error handling fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
faroyam committed Aug 19, 2018
1 parent d119624 commit 5dfcbb5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

func main() {
if len(os.Args) < 3 {
log.Println("first argument ia username\nsecond argument is remote ip addr")
fmt.Println("first argument ia username\nsecond argument is remote ip addr")
return
}
username := os.Args[1]
Expand All @@ -40,9 +40,10 @@ type message struct {

func server(wg *sync.WaitGroup, c chan bool) {
defer wg.Done()
ln, err := net.Listen("tcp", ":8081")
ln, err := net.Listen("tcp", ":49228")
if err != nil {
log.Println(err)
log.Println("Starting listener error!")
return
}
defer ln.Close()
for {
Expand Down Expand Up @@ -72,7 +73,7 @@ func server(wg *sync.WaitGroup, c chan bool) {
func send(remoteAddr string, m chan message, c chan bool) {
CONNECTION:
for {
conn, err := net.Dial("tcp", remoteAddr+":8081")
conn, err := net.Dial("tcp", remoteAddr+":49228")

if err != nil {
log.Println("Connecting...")
Expand Down

0 comments on commit 5dfcbb5

Please sign in to comment.