![]()
|
example codeThe following is a run-through of the example program supplied with libshout - example.c.
First, the libshout header has to be included.
Next, the shout_conn_t structure must
be declared.
shout_init_connection() must be
called to initialize the conn structure with default values.
Now, the conn structure must be filled out with the data for this
connection.
Try to connect.
Here's the read loop:
The code is reading blocks of data, and sending them straight into shout_send_data(). The code also makes sure to break out if there are any problems or if we run out of data to send. The shout_sleep() call at the end makes sure we're pausing once in a while and not flooding the server. It also makes sure the data is going at the correct rate.
Once the read loops is over, we disconnect:
And that's it! Libshout does all the dirty work inside of shout_send_data() so that developers can concentrate on adding cool new features.
The full source for example.c can be found with the libshout
distribution in example.c.
|