summaryrefslogtreecommitdiffstats
path: root/src/socket-client.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2004-07-15 00:16:27 +0000
committerLennart Poettering <lennart@poettering.net>2004-07-15 00:16:27 +0000
commit1416fef19796fa5372e6ed02cfd18574a040255f (patch)
treebf37d45b832d23105de2f6849714742294090529 /src/socket-client.c
parente83b7106ac1c008d1fa077c4bbb68423a46e604c (diff)
implement client side TCP support
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@67 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/socket-client.c')
-rw-r--r--src/socket-client.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/socket-client.c b/src/socket-client.c
index 8b2bd384..b1e609ab 100644
--- a/src/socket-client.c
+++ b/src/socket-client.c
@@ -80,7 +80,7 @@ static void connect_fixed_cb(struct pa_mainloop_api *m, void *id, void *userdata
static void connect_io_cb(struct pa_mainloop_api*m, void *id, int fd, enum pa_mainloop_api_io_events events, void *userdata) {
struct pa_socket_client *c = userdata;
- assert(m && c && c->io_source == id && fd >= 0 && events == PA_MAINLOOP_API_IO_EVENT_OUTPUT);
+ assert(m && c && c->io_source == id && fd >= 0);
m->cancel_io(m, c->io_source);
c->io_source = NULL;
do_call(c);
@@ -93,7 +93,7 @@ static int do_connect(struct pa_socket_client *c, const struct sockaddr *sa, soc
pa_make_nonblock_fd(c->fd);
if ((r = connect(c->fd, sa, len)) < 0) {
- if (r != EINPROGRESS) {
+ if (errno != EINPROGRESS) {
fprintf(stderr, "connect(): %s\n", strerror(errno));
return -1;
}
@@ -165,7 +165,34 @@ fail:
pa_socket_client_free(c);
return NULL;
}
+
+struct pa_socket_client* pa_socket_client_new_sockaddr(struct pa_mainloop_api *m, const struct sockaddr *sa, size_t salen) {
+ struct pa_socket_client *c;
+ assert(m && sa);
+ c = pa_socket_client_new(m);
+ assert(c);
+
+ if ((c->fd = socket(sa->sa_family, SOCK_STREAM, 0)) < 0) {
+ fprintf(stderr, "socket(): %s\n", strerror(errno));
+ goto fail;
+ }
+
+ if (sa->sa_family == AF_INET)
+ pa_socket_tcp_low_delay(c->fd);
+ else
+ pa_socket_low_delay(c->fd);
+
+ if (do_connect(c, sa, salen) < 0)
+ goto fail;
+ return c;
+
+fail:
+ pa_socket_client_free(c);
+ return NULL;
+
+}
+
void pa_socket_client_free(struct pa_socket_client *c) {
assert(c && c->mainloop);
if (c->io_source)