Low Level Programming Sessions Summary 15
8th February
This week we talked more about networking and IP once more. We discussed the differences between TCP and UDP. TCP seems like the standard way of doing things, allowing one to send data to multiple access ports and to communicate more readily. UDP however, seems to be more useful for sending data to just one person, instead of over a network. There is more overhead with UDP but it is more lightweight, making it a better protocal overall, but has it's own shortcomings with that lightness. TCP however, is a stream protocal and doesn't suffer from the boundaries imposed by UDP.
Each communication method sends raw bytes of data, not variables or blocks, simple raw bytes. This can be extremely limiting, so, another method can be used. Data can be encoded into 'packets' which can then be sent along the network link and unpacked on the other side when received to be printed to the client.
Connecting to a server requires a socket and a client. A listener is deployed to listen for incoming connections. Once it sees a connection, it generates a new socket and places the client in that socket of the list. This however, is a blocking call and therefore stops the program running. So instead, the server can use a timeout so that the call is only blocking the thread for a short time, allowing somewhat normal functionality.
The SFML packet system is cross platform and can be used to transfer to all kinds of devices. It can be used to send any kind of thing, like gameobjects, or just chars. However, to send a custom class, one must create an entire operator function which can send and stream the data.
The best part about using SFML is that it is OOP orientated, therefore you can inherit from the classes used. It is entirely possible to create a custom packet system by inheriting from the default packet.
Overall, I quite enjoyed getting the hang of network programming and while we didn't get our chat server running quite as we expected, it was nice being able to see things working, and a nice introduction to using multiple solution files.
No comments:
Post a Comment