Saturday, December 5, 2009

Using netcat to stream music with mpg123

Like my previos post, i used netcat as a simple one page webserver, basically having netcat listen on port 80 and anything that connects to port 80, send them an html file. Simple enough. This post shows how we can use the same concept and listen on a port and send an mp3 over the network to connecting clients. Mpg123 is a command line utility that basically play music on the command line. You can see how netcat and mpg123 is used together to stream music accross the network.


[server] # cat music_file.mp3 | nc -l -p 4444 //listens on port 4444 and cats the contents of the mp3 file accross the network

[client] # nc 4444 | mpg123 - // connects to the server on port 4444 and plays what ever data comes through its connection

Resources/Good reading:

No comments:

Post a Comment