Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: TCP Server does not react instantly  (Read 2102 times)

0 Members and 1 Guest are viewing this topic.

JoshuaBehrens

  • Newbie
  • *
  • Posts: 35
    • View Profile
TCP Server does not react instantly
« on: April 01, 2013, 08:08:01 pm »
Hey guys,

I'm trying to get small tcp server working. At first I put the project in as attachment. You have to build it for your own due to the upload limitations of the forum. Everything but the network part is cut out. There are some things I don't understand why they are how they are. The server reacts only when I send a broadcast message although it has it's own thread. Also connectings and disconnectings are not send right. Not all receive the messages (there is a pattern due to the order of connects but I can't figure out why it is as it is). I'm currenly doing a video to this. I'll post it in a few minutes.
I hope someone can give me some hints to fix this.

JoshuaBehrens

[attachment deleted by admin]
« Last Edit: April 01, 2013, 09:01:13 pm by JoshuaBehrens »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11016
    • View Profile
    • development blog
    • Email
Re: TCP Server does not react instantly
« Reply #1 on: April 01, 2013, 08:19:35 pm »
Please make a minimal and complete example and don't just throw the whole code at us and say "it doesn't work, figure it out for me!"

Networking is not the easiest topic and you should have a solid understanding on what you're doing. There are many resources on the internet to get this basic understanding. A good starting point are the FAQ on the SFML wiki. If you don't understand the concept of TCP you should probably read some Wikipedia articles.
Then after you understand what's going on you can go back to your code and adapt it to the way it's supposed to be used and if you still have problems come back here with a minimal and complete example that reproduces the problem and state exactly, what you don't understand and what doesn't work exactly! :)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

JoshuaBehrens

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: TCP Server does not react instantly
« Reply #2 on: April 01, 2013, 09:25:10 pm »
Sorry it shouldn't sound selfish(?). I currently can't stream nor upload because my internet is making trouble. I already worked with tcp with .Net and Visual Basic. I already cut off a lot so, it's not the "whole code". It is the network classes I build with the relevant messages and how I send them and a small console workaround to see what is happening. I have just no idea why the first console gets the message it joined, the second parallel console gets the messages that two consoles are there, the third parallel console ... I also tested with a client on a second pc in my LAN. All clients receive a user broadcast by the server so the connections work. Also the client can send the a message to the server but this is extracted out of the example, so the connection works bidirectional. But I don't know why the a client doesn't get a user joined message when an other client joins afterwards.
I think I got why the server doesn't show that what he receives. Maybe the std::getline also stops output because the main thread waits here and everything is put out after I push enter to send a broadcast.

 

anything