#local tcp task
25 messages · Page 1 of 1 (latest)
Working on Linux as you see message interpreted twice
But on receiver side once but the issue is the message repeats twice if condition makes timestamp removed
Your function is super long. It's a bit difficult to read with that many locks and unlocks etc.
@worn otter any help or videos I need help
Welcome to TCP-Chat!
Bob
Hello!
[13-09-2024 20:05:53][Bob]: Hello!
What's up?
[13-09-2024 20:06:05][Bob]: What's up?
How well does this work?
[13-09-2024 20:06:25][Bob]: How well does this work?
Does this work as it should?
[13-09-2024 20:06:33][Bob]: Does this work as it should?
I see no problems.
[13-09-2024 20:06:42][Bob]: I see no problems.
I don't see any issues.
Your screenshot looks good too.
@worn otter the issue is that name can't be empty so if I not write my name it doesn't stop
What do you mean?
Ah, hmmm
The best thing you could do is start separating code out so that it becomes easier to maintain and debug.
Is it OK if I say I can't or possible this way
I don't understand.
Actually my colleagues code so I just need to debug
Why do you have to debug it?
We have to submit to audit
Submit to where? Audit by whom?
School project
So your issue is somewhere around here?
// Read the name from the client
var name string
for {
if scanner.Scan() {
name = scanner.Text()
if name != "" {
break
}
fmt.Println("Name cannot be empty. \n Please enter your name again")
}
if err := scanner.Err(); err != nil {
log.Println("Error reading from client:", err)
return
}
}
What do you want to do when they don't enter a name?
The best thing would be to tell the client that it's not valid and disconnect.
And instead of printing it, send a response.
And then return from the handler.
What error pops up?