C:\Users\Roman\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\__init__.py
['ConnectTimeout', 'ConnectionError', 'DependencyWarning', 'FileModeWarning', 'HTTPError', 'NullHandler', 'PreparedRequest', 'ReadTimeout', 'Request', 'RequestException', 'RequestsDependencyWarning', 'Response', 'Session', 'Timeout', 'TooManyRedirects', 'URLRequired', '__author__', '__author_email__', '__build__', '__builtins__', '__cached__', '__cake__', '__copyright__', '__description__', '__doc__', '__file__', '__license__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '__title__', '__url__', '__version__', '_check_cryptography', '_internal_utils', 'adapters', 'api', 'auth', 'certs', 'chardet', 'check_compatibility', 'codes', 'compat', 'cookies', 'delete', 'exceptions', 'get', 'head', 'hooks', 'logging', 'models', 'options', 'packages', 'patch', 'post', 'put', 'request', 'session', 'sessions', 'status_codes', 'structures', 'urllib3', 'utils', 'warnings']
g++ /dir/<имя_файла>
//#include "stdafx.h"
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <fcntl.h>
#include <netinet/tcp.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <netdb.h>
#include <pulse/simple.h>
#include <pulse/error.h>
#define BUFSIZE 320
#define BLOCKSIZE 512
int fd;
int socket_connect(const char *host, in_port_t port) {
printf("Connect to: %s\n", host);
struct hostent *hp;
struct sockaddr_in addr;
int on = 1, sock;
if ((hp = gethostbyname(host)) == NULL) {
herror("gethostbyname");
return (-1);
}
bcopy(hp->h_addr, &addr.sin_addr, hp->h_length);
addr.sin_port = htons(port);
addr.sin_family = AF_INET;
sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (const char *) &on, sizeof(int));
if (sock == -1) {
perror("setsockopt");
return (-1);
}
if (connect(sock, (struct sockaddr *) &addr, sizeof(struct sockaddr_in))
== -1) {
perror("connect");
return (-1);
}
return sock;
}
int main(int argc, char*argv[]) {
char *servermessage;
const char *header = "POST /cgi-bin/transmitaudio_cgi?user=admin&pwd=Admin123 HTTP/1.1\r\nConnection: Keep-Alive\r\nContent-Type: G.711U;boundary=audio\r\n\r\n";
const char *audio = "--audio";
fd = socket_connect("192.168.2.38", atoi("80"));
write(fd, header, strlen(header));
/* The Sample format to use */
static const pa_sample_spec ss = {
.format = PA_SAMPLE_ULAW,
.rate = 8000,
.channels = 1
};
pa_simple *s_in, *s_out = NULL;
int ret = 1;
int error;
/* Create a new playback stream */
if (!(s_out = pa_simple_new(NULL, argv[0], PA_STREAM_PLAYBACK, NULL, "playback", &ss, NULL, NULL, &error))) {
fprintf(stderr, __FILE__": pa_simple_new() failed: %s\n", strerror(errno));
goto finish;
}
if (!(s_in = pa_simple_new(NULL, argv[0], PA_STREAM_RECORD, NULL, "record", &ss, NULL, NULL, &error))) {
fprintf(stderr, __FILE__": pa_simple_new() failed: %s\n", strerror(errno));
goto finish;
}
for (;;) {
uint8_t buf[BUFSIZE];
ssize_t r;
if (pa_simple_read(s_in, buf, sizeof(buf), &error) < 0) {
fprintf(stderr, __FILE__": read() failed: %s\n", strerror(errno));
goto finish;
}
if(write(fd, buf, BUFSIZE) != BUFSIZE)
printf("\nErr\n");
if(write(fd, audio, 7) != 7)
printf("\nErr\n");*/
if (pa_simple_write(s_out, buf, sizeof(buf), &error) < 0) {
fprintf(stderr, __FILE__": pa_simple_write() failed: %s\n", strerror(errno));
goto finish;
}
}
/* Make sure that every single sample was played */
if (pa_simple_drain(s_out, &error) < 0) {
fprintf(stderr, __FILE__": pa_simple_drain() failed: %s\n", strerror(errno));
goto finish;
}
ret = 0;
finish:
if(fd){
shutdown(fd, SHUT_RDWR);
close(fd);
}
if (s_in)
pa_simple_free(s_in);
if (s_out)
pa_simple_free(s_out);
return ret;
}