ext/tcp/*: Revert Zaheer changes, to make things actually work again.
Original commit message from CVS: * ext/tcp/*: Revert Zaheer changes, to make things actually work again.
This commit is contained in:
parent
ae8739f761
commit
c163b09cc4
@ -1,3 +1,7 @@
|
|||||||
|
2004-06-17 Johan Dahlin <johan@gnome.org>
|
||||||
|
|
||||||
|
* ext/tcp/*: Revert Zaheer changes.
|
||||||
|
|
||||||
2004-06-16 Wim Taymans <wim@fluendo.com>
|
2004-06-16 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
* sys/v4l/gstv4lmjpegsrc.c: (gst_v4lmjpegsrc_get):
|
* sys/v4l/gstv4lmjpegsrc.c: (gst_v4lmjpegsrc_get):
|
||||||
|
@ -302,9 +302,8 @@ gst_tcpclientsink_get_property (GObject * object, guint prop_id, GValue * value,
|
|||||||
static gboolean
|
static gboolean
|
||||||
gst_tcpclientsink_init_send (GstTCPClientSink * this)
|
gst_tcpclientsink_init_send (GstTCPClientSink * this)
|
||||||
{
|
{
|
||||||
int ret, error;
|
int ret;
|
||||||
gchar *tempport;
|
gchar *ip;
|
||||||
struct addrinfo hints, *res, *ressave;
|
|
||||||
|
|
||||||
/* reset caps_sent flag */
|
/* reset caps_sent flag */
|
||||||
this->caps_sent = FALSE;
|
this->caps_sent = FALSE;
|
||||||
@ -312,51 +311,46 @@ gst_tcpclientsink_init_send (GstTCPClientSink * this)
|
|||||||
/* create sending client socket */
|
/* create sending client socket */
|
||||||
GST_DEBUG_OBJECT (this, "opening sending client socket to %s:%d", this->host,
|
GST_DEBUG_OBJECT (this, "opening sending client socket to %s:%d", this->host,
|
||||||
this->port);
|
this->port);
|
||||||
|
if ((this->sock_fd = socket (AF_INET, SOCK_STREAM, 0)) == -1) {
|
||||||
memset (&hints, 0, sizeof (struct addrinfo));
|
GST_ELEMENT_ERROR (this, RESOURCE, OPEN_WRITE, (NULL), GST_ERROR_SYSTEM);
|
||||||
hints.ai_family = AF_UNSPEC;
|
|
||||||
hints.ai_socktype = SOCK_STREAM;
|
|
||||||
tempport = g_strdup_printf ("%d", this->port);
|
|
||||||
error = getaddrinfo (this->host, tempport, &hints, &res);
|
|
||||||
g_free (tempport);
|
|
||||||
if (error != 0) {
|
|
||||||
GST_ELEMENT_ERROR (this, RESOURCE, OPEN_READ,
|
|
||||||
(_("Error getting address info (%s:%d): %s"), this->host, this->port,
|
|
||||||
gai_strerror (error)), (NULL));
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ressave = res;
|
|
||||||
|
|
||||||
this->sock_fd = -1;
|
|
||||||
|
|
||||||
while (res) {
|
|
||||||
this->sock_fd = socket (res->ai_family, res->ai_socktype, res->ai_protocol);
|
|
||||||
if (this->sock_fd >= 0) {
|
|
||||||
ret = connect (this->sock_fd, res->ai_addr, res->ai_addrlen);
|
|
||||||
if (ret == 0)
|
|
||||||
break;
|
|
||||||
close (this->sock_fd);
|
|
||||||
this->sock_fd = -1;
|
|
||||||
}
|
|
||||||
res = res->ai_next;
|
|
||||||
}
|
|
||||||
freeaddrinfo (ressave);
|
|
||||||
|
|
||||||
if (errno == ECONNREFUSED) {
|
|
||||||
GST_ELEMENT_ERROR (this, RESOURCE, OPEN_READ,
|
|
||||||
(_("Connection to %s:%d refused."), this->host, this->port), (NULL));
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this->sock_fd == -1) {
|
|
||||||
GST_ELEMENT_ERROR (this, RESOURCE, OPEN_READ, (NULL), GST_ERROR_SYSTEM);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (this, "opened sending client socket with fd %d",
|
GST_DEBUG_OBJECT (this, "opened sending client socket with fd %d",
|
||||||
this->sock_fd);
|
this->sock_fd);
|
||||||
|
|
||||||
|
/* look up name if we need to */
|
||||||
|
ip = gst_tcp_host_to_ip (GST_ELEMENT (this), this->host);
|
||||||
|
if (!ip)
|
||||||
|
return FALSE;
|
||||||
|
GST_DEBUG_OBJECT (this, "IP address for host %s is %s", this->host, ip);
|
||||||
|
|
||||||
|
/* connect to server */
|
||||||
|
memset (&this->server_sin, 0, sizeof (this->server_sin));
|
||||||
|
this->server_sin.sin_family = AF_INET; /* network socket */
|
||||||
|
this->server_sin.sin_port = htons (this->port); /* on port */
|
||||||
|
this->server_sin.sin_addr.s_addr = inet_addr (ip); /* on host ip */
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (this, "connecting to server");
|
||||||
|
ret = connect (this->sock_fd, (struct sockaddr *) &this->server_sin,
|
||||||
|
sizeof (this->server_sin));
|
||||||
|
|
||||||
|
if (ret) {
|
||||||
|
switch (errno) {
|
||||||
|
case ECONNREFUSED:
|
||||||
|
GST_ELEMENT_ERROR (this, RESOURCE, OPEN_WRITE,
|
||||||
|
(_("Connection to %s:%d refused."), this->host, this->port),
|
||||||
|
(NULL));
|
||||||
|
return FALSE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
GST_ELEMENT_ERROR (this, RESOURCE, OPEN_READ, (NULL),
|
||||||
|
("connect to %s:%d failed: %s", this->host, this->port,
|
||||||
|
g_strerror (errno)));
|
||||||
|
return FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GST_FLAG_SET (this, GST_TCPCLIENTSINK_OPEN);
|
GST_FLAG_SET (this, GST_TCPCLIENTSINK_OPEN);
|
||||||
|
|
||||||
this->data_written = 0;
|
this->data_written = 0;
|
||||||
|
@ -73,6 +73,7 @@ struct _GstTCPClientSink {
|
|||||||
/* server information */
|
/* server information */
|
||||||
int port;
|
int port;
|
||||||
gchar *host;
|
gchar *host;
|
||||||
|
struct sockaddr_in server_sin;
|
||||||
|
|
||||||
/* socket */
|
/* socket */
|
||||||
int sock_fd;
|
int sock_fd;
|
||||||
|
@ -393,60 +393,51 @@ gst_tcpclientsrc_get_property (GObject * object, guint prop_id, GValue * value,
|
|||||||
static gboolean
|
static gboolean
|
||||||
gst_tcpclientsrc_init_receive (GstTCPClientSrc * this)
|
gst_tcpclientsrc_init_receive (GstTCPClientSrc * this)
|
||||||
{
|
{
|
||||||
int ret, error;
|
int ret;
|
||||||
gchar *tempport;
|
gchar *ip;
|
||||||
|
|
||||||
struct addrinfo hints, *res, *ressave;
|
|
||||||
|
|
||||||
/* create receiving client socket */
|
/* create receiving client socket */
|
||||||
GST_DEBUG_OBJECT (this, "opening receiving client socket to %s:%d",
|
GST_DEBUG_OBJECT (this, "opening receiving client socket to %s:%d",
|
||||||
this->host, this->port);
|
this->host, this->port);
|
||||||
|
if ((this->sock_fd = socket (AF_INET, SOCK_STREAM, 0)) == -1) {
|
||||||
memset (&hints, 0, sizeof (struct addrinfo));
|
|
||||||
|
|
||||||
hints.ai_family = AF_UNSPEC;
|
|
||||||
hints.ai_socktype = SOCK_STREAM;
|
|
||||||
|
|
||||||
tempport = g_strdup_printf ("%d", this->port);
|
|
||||||
|
|
||||||
error = getaddrinfo (this->host, tempport, &hints, &res);
|
|
||||||
g_free (tempport);
|
|
||||||
if (error != 0) {
|
|
||||||
GST_ELEMENT_ERROR (this, RESOURCE, OPEN_READ,
|
|
||||||
(_("Error getting address info (%s:%d): %s"), this->host, this->port,
|
|
||||||
gai_strerror (error)), (NULL));
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
ressave = res;
|
|
||||||
|
|
||||||
this->sock_fd = -1;
|
|
||||||
while (res) {
|
|
||||||
this->sock_fd = socket (res->ai_family, res->ai_socktype, res->ai_protocol);
|
|
||||||
if (this->sock_fd >= 0) {
|
|
||||||
ret = connect (this->sock_fd, res->ai_addr, res->ai_addrlen);
|
|
||||||
if (ret == 0)
|
|
||||||
break;
|
|
||||||
close (this->sock_fd);
|
|
||||||
this->sock_fd = -1;
|
|
||||||
}
|
|
||||||
res = res->ai_next;
|
|
||||||
}
|
|
||||||
freeaddrinfo (ressave);
|
|
||||||
|
|
||||||
if (errno == ECONNREFUSED) {
|
|
||||||
GST_ELEMENT_ERROR (this, RESOURCE, OPEN_READ,
|
|
||||||
(_("Connection to %s:%d refused."), this->host, this->port), (NULL));
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this->sock_fd == -1) {
|
|
||||||
GST_ELEMENT_ERROR (this, RESOURCE, OPEN_READ, (NULL), GST_ERROR_SYSTEM);
|
GST_ELEMENT_ERROR (this, RESOURCE, OPEN_READ, (NULL), GST_ERROR_SYSTEM);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
GST_DEBUG_OBJECT (this, "opened receiving client socket with fd %d",
|
GST_DEBUG_OBJECT (this, "opened receiving client socket with fd %d",
|
||||||
this->sock_fd);
|
this->sock_fd);
|
||||||
|
|
||||||
|
/* look up name if we need to */
|
||||||
|
ip = gst_tcp_host_to_ip (GST_ELEMENT (this), this->host);
|
||||||
|
if (!ip)
|
||||||
|
return FALSE;
|
||||||
|
GST_DEBUG_OBJECT (this, "IP address for host %s is %s", this->host, ip);
|
||||||
|
|
||||||
|
/* connect to server */
|
||||||
|
memset (&this->server_sin, 0, sizeof (this->server_sin));
|
||||||
|
this->server_sin.sin_family = AF_INET; /* network socket */
|
||||||
|
this->server_sin.sin_port = htons (this->port); /* on port */
|
||||||
|
this->server_sin.sin_addr.s_addr = inet_addr (ip); /* on host ip */
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (this, "connecting to server");
|
||||||
|
ret = connect (this->sock_fd, (struct sockaddr *) &this->server_sin,
|
||||||
|
sizeof (this->server_sin));
|
||||||
|
|
||||||
|
if (ret) {
|
||||||
|
switch (errno) {
|
||||||
|
case ECONNREFUSED:
|
||||||
|
GST_ELEMENT_ERROR (this, RESOURCE, OPEN_READ,
|
||||||
|
(_("Connection to %s:%d refused."), this->host, this->port),
|
||||||
|
(NULL));
|
||||||
|
return FALSE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
GST_ELEMENT_ERROR (this, RESOURCE, OPEN_READ, (NULL),
|
||||||
|
("connect to %s:%d failed: %s", this->host, this->port,
|
||||||
|
g_strerror (errno)));
|
||||||
|
return FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this->send_discont = TRUE;
|
this->send_discont = TRUE;
|
||||||
this->buffer_after_discont = NULL;
|
this->buffer_after_discont = NULL;
|
||||||
|
@ -62,6 +62,7 @@ struct _GstTCPClientSrc {
|
|||||||
/* server information */
|
/* server information */
|
||||||
int port;
|
int port;
|
||||||
gchar *host;
|
gchar *host;
|
||||||
|
struct sockaddr_in server_sin;
|
||||||
|
|
||||||
/* socket */
|
/* socket */
|
||||||
int sock_fd;
|
int sock_fd;
|
||||||
|
@ -29,8 +29,6 @@
|
|||||||
#include <sys/filio.h>
|
#include <sys/filio.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
#include "gsttcpserversink.h"
|
#include "gsttcpserversink.h"
|
||||||
#include "gsttcp-marshal.h"
|
#include "gsttcp-marshal.h"
|
||||||
|
|
||||||
@ -189,7 +187,6 @@ gst_tcpserversink_init (GstTCPServerSink * this)
|
|||||||
|
|
||||||
this->protocol = GST_TCP_PROTOCOL_TYPE_NONE;
|
this->protocol = GST_TCP_PROTOCOL_TYPE_NONE;
|
||||||
this->clock = NULL;
|
this->clock = NULL;
|
||||||
this->host = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -211,11 +208,8 @@ gst_tcpserversink_handle_server_read (GstTCPServerSink * sink)
|
|||||||
{
|
{
|
||||||
/* new client */
|
/* new client */
|
||||||
int client_sock_fd;
|
int client_sock_fd;
|
||||||
struct sockaddr_storage client_address;
|
struct sockaddr_in client_address;
|
||||||
int client_address_len;
|
int client_address_len;
|
||||||
char clienthost[NI_MAXHOST];
|
|
||||||
char clientservice[NI_MAXSERV];
|
|
||||||
int error;
|
|
||||||
|
|
||||||
client_sock_fd =
|
client_sock_fd =
|
||||||
accept (sink->server_sock_fd, (struct sockaddr *) &client_address,
|
accept (sink->server_sock_fd, (struct sockaddr *) &client_address,
|
||||||
@ -226,19 +220,11 @@ gst_tcpserversink_handle_server_read (GstTCPServerSink * sink)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
FD_SET (client_sock_fd, &(sink->clientfds));
|
FD_SET (client_sock_fd, &(sink->clientfds));
|
||||||
error = getnameinfo ((struct sockaddr *) &client_address, client_address_len,
|
GST_DEBUG_OBJECT (sink, "added new client ip %s with fd %d",
|
||||||
clienthost, sizeof (clienthost), clientservice,
|
inet_ntoa (client_address.sin_addr), client_sock_fd);
|
||||||
sizeof (clientservice), NI_NUMERICHOST);
|
|
||||||
if (error != 0) {
|
|
||||||
GST_DEBUG_OBJECT (sink, "added new client address %s with fd %d",
|
|
||||||
clienthost, client_sock_fd);
|
|
||||||
} else {
|
|
||||||
GST_DEBUG_OBJECT (sink, "problem error received from getnameinfo: %d",
|
|
||||||
error);
|
|
||||||
}
|
|
||||||
g_signal_emit (G_OBJECT (sink),
|
g_signal_emit (G_OBJECT (sink),
|
||||||
gst_tcpserversink_signals[SIGNAL_CLIENT_ADDED], 0,
|
gst_tcpserversink_signals[SIGNAL_CLIENT_ADDED], 0,
|
||||||
g_strdup (clienthost), client_sock_fd);
|
inet_ntoa (client_address.sin_addr), client_sock_fd);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -560,49 +546,15 @@ gst_tcpserversink_get_property (GObject * object, guint prop_id, GValue * value,
|
|||||||
static gboolean
|
static gboolean
|
||||||
gst_tcpserversink_init_send (GstTCPServerSink * this)
|
gst_tcpserversink_init_send (GstTCPServerSink * this)
|
||||||
{
|
{
|
||||||
int ret, error;
|
int ret;
|
||||||
struct addrinfo hints, *res, *ressave;
|
|
||||||
char *tempport;
|
|
||||||
|
|
||||||
|
/* create sending server socket */
|
||||||
/* name the socket */
|
if ((this->server_sock_fd = socket (AF_INET, SOCK_STREAM, 0)) == -1) {
|
||||||
memset (&hints, 0, sizeof (struct addrinfo));
|
GST_ELEMENT_ERROR (this, RESOURCE, OPEN_WRITE, (NULL), GST_ERROR_SYSTEM);
|
||||||
hints.ai_flags = AI_PASSIVE;
|
|
||||||
hints.ai_family = AF_UNSPEC;
|
|
||||||
hints.ai_socktype = SOCK_STREAM;
|
|
||||||
tempport = g_strdup_printf ("%d", this->server_port);
|
|
||||||
|
|
||||||
error = getaddrinfo (this->host, tempport, &hints, &res);
|
|
||||||
g_free (tempport);
|
|
||||||
if (error != 0) {
|
|
||||||
GST_ELEMENT_ERROR (this, RESOURCE, OPEN_READ, (NULL),
|
|
||||||
("getaddrinfo failed: %s", gai_strerror (error)));
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
ressave = res;
|
|
||||||
|
|
||||||
/* Try open socket with each address getaddrinfo returned, until getting
|
|
||||||
a valid listening socket */
|
|
||||||
this->server_sock_fd = -1;
|
|
||||||
while (res) {
|
|
||||||
this->server_sock_fd =
|
|
||||||
socket (res->ai_family, res->ai_socktype, res->ai_protocol);
|
|
||||||
if (this->server_sock_fd >= 0) {
|
|
||||||
ret = bind (this->server_sock_fd, res->ai_addr, res->ai_addrlen);
|
|
||||||
if (ret == 0)
|
|
||||||
break;
|
|
||||||
close (this->server_sock_fd);
|
|
||||||
this->server_sock_fd = -1;
|
|
||||||
}
|
|
||||||
res = res->ai_next;
|
|
||||||
}
|
|
||||||
freeaddrinfo (ressave);
|
|
||||||
|
|
||||||
if (this->server_sock_fd < 0) {
|
|
||||||
GST_ELEMENT_ERROR (this, RESOURCE, OPEN_READ, (NULL),
|
|
||||||
("bind failed: %s", g_strerror (errno)));
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
GST_DEBUG_OBJECT (this, "opened sending server socket with fd %d",
|
||||||
|
this->server_sock_fd);
|
||||||
|
|
||||||
/* make address reusable */
|
/* make address reusable */
|
||||||
if (setsockopt (this->server_sock_fd, SOL_SOCKET, SO_REUSEADDR, &ret,
|
if (setsockopt (this->server_sock_fd, SOL_SOCKET, SO_REUSEADDR, &ret,
|
||||||
@ -618,6 +570,28 @@ gst_tcpserversink_init_send (GstTCPServerSink * this)
|
|||||||
("Could not setsockopt: %s", g_strerror (errno)));
|
("Could not setsockopt: %s", g_strerror (errno)));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* name the socket */
|
||||||
|
memset (&this->server_sin, 0, sizeof (this->server_sin));
|
||||||
|
this->server_sin.sin_family = AF_INET; /* network socket */
|
||||||
|
this->server_sin.sin_port = htons (this->server_port); /* on port */
|
||||||
|
this->server_sin.sin_addr.s_addr = htonl (INADDR_ANY); /* for hosts */
|
||||||
|
|
||||||
|
/* bind it */
|
||||||
|
GST_DEBUG_OBJECT (this, "binding server socket to address");
|
||||||
|
ret = bind (this->server_sock_fd, (struct sockaddr *) &this->server_sin,
|
||||||
|
sizeof (this->server_sin));
|
||||||
|
|
||||||
|
if (ret) {
|
||||||
|
switch (errno) {
|
||||||
|
default:
|
||||||
|
GST_ELEMENT_ERROR (this, RESOURCE, OPEN_READ, (NULL),
|
||||||
|
("bind failed: %s", g_strerror (errno)));
|
||||||
|
return FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* set the server socket to nonblocking */
|
/* set the server socket to nonblocking */
|
||||||
fcntl (this->server_sock_fd, F_SETFL, O_NONBLOCK);
|
fcntl (this->server_sock_fd, F_SETFL, O_NONBLOCK);
|
||||||
|
|
||||||
|
@ -73,6 +73,7 @@ struct _GstTCPServerSink {
|
|||||||
/* server information */
|
/* server information */
|
||||||
int server_port;
|
int server_port;
|
||||||
gchar *host;
|
gchar *host;
|
||||||
|
struct sockaddr_in server_sin;
|
||||||
|
|
||||||
/* socket */
|
/* socket */
|
||||||
int server_sock_fd;
|
int server_sock_fd;
|
||||||
|
@ -456,50 +456,18 @@ gst_tcpserversrc_get_property (GObject * object, guint prop_id, GValue * value,
|
|||||||
static gboolean
|
static gboolean
|
||||||
gst_tcpserversrc_init_receive (GstTCPServerSrc * this)
|
gst_tcpserversrc_init_receive (GstTCPServerSrc * this)
|
||||||
{
|
{
|
||||||
int ret, error;
|
int ret;
|
||||||
struct addrinfo hints, *res, *ressave;
|
|
||||||
gchar *tempport;
|
|
||||||
struct sockaddr_storage client_address;
|
|
||||||
int client_address_len;
|
|
||||||
|
|
||||||
/* name the socket */
|
/* reset caps_received flag */
|
||||||
memset (&hints, 0, sizeof (struct addrinfo));
|
this->caps_received = FALSE;
|
||||||
hints.ai_flags = AI_PASSIVE;
|
|
||||||
hints.ai_family = AF_UNSPEC;
|
|
||||||
hints.ai_socktype = SOCK_STREAM;
|
|
||||||
tempport = g_strdup_printf ("%d", this->server_port);
|
|
||||||
|
|
||||||
error = getaddrinfo (this->host, tempport, &hints, &res);
|
/* create the server listener socket */
|
||||||
g_free (tempport);
|
if ((this->server_sock_fd = socket (AF_INET, SOCK_STREAM, 0)) == -1) {
|
||||||
if (error != 0) {
|
GST_ELEMENT_ERROR (this, RESOURCE, OPEN_READ, (NULL), GST_ERROR_SYSTEM);
|
||||||
GST_ELEMENT_ERROR (this, RESOURCE, OPEN_READ, (NULL),
|
|
||||||
("getaddrinfo failed: %s", gai_strerror (error)));
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
ressave = res;
|
|
||||||
|
|
||||||
/* Try open socket with each address getaddrinfo returned, until getting
|
|
||||||
a valid listening socket */
|
|
||||||
this->server_sock_fd = -1;
|
|
||||||
while (res) {
|
|
||||||
this->server_sock_fd =
|
|
||||||
socket (res->ai_family, res->ai_socktype, res->ai_protocol);
|
|
||||||
if (this->server_sock_fd >= 0) {
|
|
||||||
ret = bind (this->server_sock_fd, res->ai_addr, res->ai_addrlen);
|
|
||||||
if (ret == 0)
|
|
||||||
break;
|
|
||||||
close (this->server_sock_fd);
|
|
||||||
this->server_sock_fd = -1;
|
|
||||||
}
|
|
||||||
res = res->ai_next;
|
|
||||||
}
|
|
||||||
freeaddrinfo (ressave);
|
|
||||||
|
|
||||||
if (this->server_sock_fd < 0) {
|
|
||||||
GST_ELEMENT_ERROR (this, RESOURCE, OPEN_READ, (NULL),
|
|
||||||
("bind failed: %s", g_strerror (errno)));
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
GST_DEBUG_OBJECT (this, "opened receiving server socket with fd %d",
|
||||||
|
this->server_sock_fd);
|
||||||
|
|
||||||
/* make address reusable */
|
/* make address reusable */
|
||||||
if (setsockopt (this->server_sock_fd, SOL_SOCKET, SO_REUSEADDR, &ret,
|
if (setsockopt (this->server_sock_fd, SOL_SOCKET, SO_REUSEADDR, &ret,
|
||||||
@ -509,8 +477,35 @@ gst_tcpserversrc_init_receive (GstTCPServerSrc * this)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* reset caps_received flag */
|
/* name the socket */
|
||||||
this->caps_received = FALSE;
|
memset (&this->server_sin, 0, sizeof (this->server_sin));
|
||||||
|
this->server_sin.sin_family = AF_INET; /* network socket */
|
||||||
|
this->server_sin.sin_port = htons (this->server_port); /* on port */
|
||||||
|
if (this->host) {
|
||||||
|
gchar *host = gst_tcp_host_to_ip (GST_ELEMENT (this), this->host);
|
||||||
|
|
||||||
|
if (!host)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
this->server_sin.sin_addr.s_addr = inet_addr (host);
|
||||||
|
g_free (host);
|
||||||
|
} else
|
||||||
|
this->server_sin.sin_addr.s_addr = htonl (INADDR_ANY);
|
||||||
|
|
||||||
|
/* bind it */
|
||||||
|
GST_DEBUG_OBJECT (this, "binding server socket to address");
|
||||||
|
ret = bind (this->server_sock_fd, (struct sockaddr *) &this->server_sin,
|
||||||
|
sizeof (this->server_sin));
|
||||||
|
|
||||||
|
if (ret) {
|
||||||
|
switch (errno) {
|
||||||
|
default:
|
||||||
|
GST_ELEMENT_ERROR (this, RESOURCE, OPEN_READ, (NULL),
|
||||||
|
("bind failed: %s", g_strerror (errno)));
|
||||||
|
return FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (this, "listening on server socket %d with queue of %d",
|
GST_DEBUG_OBJECT (this, "listening on server socket %d with queue of %d",
|
||||||
this->server_sock_fd, TCP_BACKLOG);
|
this->server_sock_fd, TCP_BACKLOG);
|
||||||
@ -524,8 +519,8 @@ gst_tcpserversrc_init_receive (GstTCPServerSrc * this)
|
|||||||
somewhere else */
|
somewhere else */
|
||||||
GST_DEBUG_OBJECT (this, "waiting for client");
|
GST_DEBUG_OBJECT (this, "waiting for client");
|
||||||
this->client_sock_fd =
|
this->client_sock_fd =
|
||||||
accept (this->server_sock_fd, (struct sockaddr *) &client_address,
|
accept (this->server_sock_fd, (struct sockaddr *) &this->client_sin,
|
||||||
&client_address_len);
|
&this->client_sin_len);
|
||||||
if (this->client_sock_fd == -1) {
|
if (this->client_sock_fd == -1) {
|
||||||
GST_ELEMENT_ERROR (this, RESOURCE, OPEN_READ, (NULL),
|
GST_ELEMENT_ERROR (this, RESOURCE, OPEN_READ, (NULL),
|
||||||
("Could not accept client on server socket: %s", g_strerror (errno)));
|
("Could not accept client on server socket: %s", g_strerror (errno)));
|
||||||
|
@ -72,6 +72,8 @@ struct _GstTCPServerSrc {
|
|||||||
int server_sock_fd;
|
int server_sock_fd;
|
||||||
|
|
||||||
/* client information */
|
/* client information */
|
||||||
|
struct sockaddr_in client_sin;
|
||||||
|
socklen_t client_sin_len;
|
||||||
int client_sock_fd;
|
int client_sock_fd;
|
||||||
|
|
||||||
/* number of bytes we've gotten */
|
/* number of bytes we've gotten */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user