



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
How to send score messages in network applications using a structure as a buffer. It covers the need to send player and opponent scores, the use of a structure to simplify programming logic, and the mechanics of buffer use. An excerpt from a university lecture on systems programming.
Typology: Study notes
1 / 5
This page cannot be seen from the preview
Don't miss anything!




Systems Programming Richard Anthony, Computer Science, The University of Greenwich
This first slide is part of lecture 4 - Network Application Development part 2 (it is included here to set the scene)
In practice, we can use the structure itself as the buffer, since it is a pre- allocated, fixed-size block of memory: cPlayerName iPlayerScore cOpponentName iOpponentScore 20 bytes 4 bytes 20 bytes (^) 4 bytes struct Score_message Message; will create an instance of the structure The notation (char*) &Message is equivallent to the addrerss of the start of the sizeof(Score_message) will return the value 28 (the length of the message i.e Therefore we can use the structure directly as the buffer, in for example the ca int iBytesSent = send( iSocket, (char*) &Message , sizeof(Message) , 0 ); (i.e. The buffer is defined precisely, by the combination of start address and le
Buffer – memory space allocated, large enough to hold the data expected Buffer containing data to be sent Operating- system maintained communication buffer – holds received messages until passed to owner process The network separates the sender and Application process (in this example this is the server, sending a Score-message to a client) ‘send’ call ‘recv’ call Applicati on process (in this example this is the client) Transfer
Transfer