summaryrefslogtreecommitdiffstats
path: root/gst/udp/gstudpsink.c
diff options
context:
space:
mode:
authorZeeshan Ali <zeenix@gmail.com>2003-05-22 19:38:14 +0000
committerZeeshan Ali <zeenix@gmail.com>2003-05-22 19:38:14 +0000
commit700f13fa7f64c0cd1a200a622956dddc29d54e6b (patch)
tree72ba3b35c46af830e0bcff1c579a669d468f1351 /gst/udp/gstudpsink.c
parent29f6eae110712074e1a84340eb3d172fb4b1e434 (diff)
localhost should not be looked-up and the user should be able to able to use IP instead of hostname
Original commit message from CVS: localhost should not be looked-up and the user should be able to able to use IP instead of hostname
Diffstat (limited to 'gst/udp/gstudpsink.c')
-rw-r--r--gst/udp/gstudpsink.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/gst/udp/gstudpsink.c b/gst/udp/gstudpsink.c
index 3c09f25b..6701a1d9 100644
--- a/gst/udp/gstudpsink.c
+++ b/gst/udp/gstudpsink.c
@@ -120,7 +120,7 @@ gst_udpsink_class_init (GstUDPSink *klass)
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_HOST,
- g_param_spec_string ("host", "nost", "The host to send the packets to",
+ g_param_spec_string ("host", "host", "The host/IP to send the packets to",
UDP_DEFAULT_HOST, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PORT,
g_param_spec_int ("port", "port", "The port to send the packets to",
@@ -368,16 +368,33 @@ static gboolean
gst_udpsink_init_send (GstUDPSink *sink)
{
struct hostent *he;
+ struct in_addr addr;
guint bc_val;
bzero (&sink->theiraddr, sizeof (sink->theiraddr));
sink->theiraddr.sin_family = AF_INET; /* host byte order */
- sink->theiraddr.sin_port = htons (sink->port); /* short, network byte order */
- if ((he = gethostbyname (sink->host)) == NULL) {
- perror("gethostbyname");
- return FALSE;
+ sink->theiraddr.sin_port = htons (sink->port); /* short, network byte order */
+
+ /* if its an IP address */
+ if (inet_aton (sink->host, &addr)) {
+ sink->theiraddr.sin_addr =
+ *((struct in_addr *) g_memdup (&addr, sizeof (addr)));
+ }
+
+ /* we dont need to lookup for localhost */
+ else if (strcmp (sink->host, UDP_DEFAULT_HOST) == 0) {
+ sink->theiraddr.sin_addr = *((struct in_addr *) sink->host);
+ }
+
+ /* if its a hostname */
+ else if ((he = gethostbyname (sink->host))) {
+ sink->theiraddr.sin_addr = *((struct in_addr *) he->h_addr);
+ }
+
+ else {
+ perror("hostname lookup error?");
+ return FALSE;
}
- sink->theiraddr.sin_addr = *((struct in_addr *) he->h_addr);
if ((sink->sock = socket (AF_INET, SOCK_DGRAM, 0)) == -1) {
perror("socket");