Hello,
This is my first post, and I'd like to start by saying I'm very impressed by SFML. It does exactly what it says on the tin.
I have a few questions regarding TCP sockets:
1) I'm setting up a host, which will need to be connected to by several clients. (I've read about socket selectors, that's not what my question's about.) Regarding the use of using a single Port on the host, I seem to be finding conflicting information.
The tutorials typically use a TcpListener, which is told to listen on a particular port. Let's say 51000. Then in the examples, if this socket finds a client, a TcpSocket is set up (which inherits port number 51000), and the Listener continues to listen. As each client connects, local port number 51000 is reused in the local socket. So we end up with a lot of sockets where the local address and port are the same as each other.
According to
http://en.wikipedia.org/wiki/Internet_socket"A server may create several concurrently established TCP sockets with the same local port number and local IP address, each mapped to its own server-child process, serving its own client process."
So this all sounds ok. However, I found this post:
https://github.com/laurentgomila/sfml/issues/150 where it was stated (although it was 2 years ago) that the behaviour of this arrangement is "basically undefined", and that different operating systems will behave differently. This makes it sound like I want to avoid the setup I've just described above.
So my first question is: what's the latest on this? Is it ok to have a host listening to lots of clients all through the same port, or is it not?
Ok, second question. Probably simpler:
If I have an established TCP connection between a host and a client, and say the client sends 100 bytes data, then I understand that because TCP is a "stream", then the host at the other end may not get this all at once.
If on the host I have configured the socket to be non-blocking, and I call the
receive function, I can expect sometimes that
received will be less than I was expecting? Lets say I only receive 90 bytes (out of the 100 I need to get my full "packet"). In this case, what's the best way to handle it? Should I wait until the next time I call receive, and then use the data to fill in the rest of my struct? Is this the point of the Packet class?
Many thanks in advance.
Ollie