3 * Copyright (c) 2006 acmesystems.it - john@acmesystems.it
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA
19 * Feedback, Bugs... info@acmesystems.it
29 #include <sys/types.h>
30 #include <netinet/in.h>
31 #include <sys/socket.h>
33 #define SOCKET_PORT 369
36 void print_usage(void){
37 printf("mp3_play_tcp IP COMANND PARAMETERS\n");
38 printf(" Commands :\n");
39 printf(" PLAY filename\n");
40 printf(" STREAM url [URL OF STREAM]\n");
41 printf(" STREAM pls [URL PLS FILE]\n");
42 printf(" VOLUME [0-255]\n");
45 printf(" BASS [0-255]\n");
48 void issue_command(unsigned char *str
, unsigned char *ip
){
50 struct sockaddr_in remote
;
53 if ((s
= socket(AF_UNIX
, SOCK_STREAM
, 0)) == -1) {
58 printf("Connecting to FOXMP3 on IP/DNS : %s ...\n", ip
);
59 if((he
=gethostbyname(ip
)) == NULL
) {
60 herror("gethostbyname");
63 if ((s
= socket(PF_INET
, SOCK_STREAM
, 0)) == -1) {
67 remote
.sin_family
= AF_INET
;
68 remote
.sin_port
= htons(SOCKET_PORT
);
69 remote
.sin_addr
= *((struct in_addr
*)he
->h_addr
);
70 memset(&(remote
.sin_zero
), '\0', 8);
72 if (connect(s
, (struct sockaddr
*)&remote
,
73 sizeof(struct sockaddr
)) == -1) {
77 printf("Connected ...\n\nSending command -> \n%s\n\n", str
);
78 if (send(s
, str
, strlen(str
), 0) == -1) {
82 if ((t
=recv(s
, str
, 2048, 0)) > 0) {
84 printf("The answer was -> \n%s\n", str
);
89 printf("Server closed connection\n");
96 int main(int argc
, char **argv
){
97 unsigned char buffer
[2048];
100 if(((!strcmp(argv
[2], "STOP")) || (!strcmp(argv
[2], "STATE")))
102 sprintf(buffer
, "%s", argv
[2]);
103 } else if(((!strcmp(argv
[2], "PLAY")) || (!strcmp(argv
[2], "VOLUME"))
104 || (!strcmp(argv
[2], "BASS"))) && (argc
== 4)){
105 sprintf(buffer
, "%s %s", argv
[2], argv
[3]);
106 } else if((!strcmp(argv
[2], "STREAM")) && (argc
== 5)
107 && ((!strcmp(argv
[3], "url")) || (!strcmp(argv
[3], "pls")))){
108 sprintf(buffer
, "%s %s %s", argv
[2], argv
[3],
112 if(buffer
[0] != '\0'){
113 issue_command(buffer
, argv
[1]);
This page took 0.061929 seconds and 5 git commands to generate.