#include #include #include #include int main(int argc, char **argv) { int i, sock; struct sockaddr_in addr; char* data = "GET AUDIO_OUTPUT_CHANNEL 1000\r\n"; char buf[20]; if(argc != 2) { printf("Usage: %s \n", argv[0]); return -1; } sock = socket(PF_INET, SOCK_STREAM, 0); if(sock == -1) { perror("socket"); return -1; } addr.sin_family = AF_INET; if(!inet_aton(argv[1], &addr.sin_addr)) { fprintf(stderr, "Invalid IP address: %s\n", argv[1]); return -1; } addr.sin_port = htons(8888); if(connect(sock, (struct sockaddr*) &addr, sizeof(addr)) == -1) { perror("connect"); return -1; } for(i = 0; i < 20; i++) { if(send(sock, data, strlen(data), 0) == -1) { perror("send"); return -1; } } if(!recv(sock, buf, 10, 0)) { perror("recv"); return -1; } exit(0); }