![]() | ![]() | ![]() | GNetwork Library Manual | ![]() |
---|
GNetworkUdpDatagram — UDP (IP datagram) socket object.
struct GNetworkUdpDatagram; struct GNetworkUdpDatagramClass; enum GNetworkUdpDatagramTtl; void gnetwork_udp_datagram_send_to (GNetworkUdpDatagram *udp, const gchar *host, guint16 port, gconstpointer data, glong length); struct GNetworkUdpTarget; GNetworkUdpTarget* gnetwork_udp_target_new (const gchar *host, guint16 port); void gnetwork_udp_target_set_host (GNetworkUdpTarget *target, const gchar *host); G_CONST_RETURN gchar* gnetwork_udp_target_get_host (const GNetworkUdpTarget *target); void gnetwork_udp_target_set_port (GNetworkUdpTarget *target, guint16 port); guint16 gnetwork_udp_target_get_port (const GNetworkUdpTarget *target); void gnetwork_udp_target_set_ip_address (GNetworkUdpTarget *target, const GNetworkIpAddress *address); G_CONST_RETURN GNetworkIpAddress* gnetwork_udp_target_get_ip_address (const GNetworkUdpTarget *target); void gnetwork_udp_target_free (GNetworkUdpTarget *target); GNetworkUdpTarget* gnetwork_udp_target_dup (const GNetworkUdpTarget *src);
"broadcast" gboolean : Read / Write / Construct "interface" gchararray : Read / Write / Construct "interface-info" GNetworkInterfaceInfo : Read / Write "port" guint : Read / Write / Construct "socket" gpointer : Read / Write "ttl" GNetworkUdpDatagramTtl : Read / Write / Construct
The GNetworkUdpDatagram object provides UDP/IP datagram services to applications. This object is primarily used for sending and receiving IP broadcasts and streaming media.
In plain GNetworkUdpDatagram objects, the GValue parameters for GNetworkDatagramIface methods and signals contain GNetworkUdpTarget structures. Subclasses may override this (GNetworkIpMulticast does) using the means described for GNetworkDatagramIface implementations. Specifically, subclasses of GNetworkUdpDatagram which override the methods and signal callbacks of GNetworkDatagramIface must chain up using GNETWORK_DATAGRAM_CALL_PARENT.
The "error" signal for GNetworkUdpDatagram objects uses the G_THREAD_ERROR, GNETWORK_DNS_ERROR, GNETWORK_DATAGRAM_ERROR, GNETWORK_UDP_DATAGRAM_ERROR, and G_THREAD_ERROR domains.
struct GNetworkUdpDatagram;
A structure representing a GNetworkUdpDatagram object. This structure contains no public data.
struct GNetworkUdpDatagramClass { };
The class structure for GNetworkUdpDatagram objects. This structure contains no public data.
typedef enum /* <prefix=GNETWORK_UDP_DATAGRAM_TTL> */ { GNETWORK_UDP_DATAGRAM_TTL_DEFAULT = -1, GNETWORK_UDP_DATAGRAM_TTL_LOCAL_HOST = 0, GNETWORK_UDP_DATAGRAM_TTL_ONE_LINK = 1, GNETWORK_UDP_DATAGRAM_TTL_LOCAL_NET = 31, GNETWORK_UDP_DATAGRAM_TTL_REGION = 63, GNETWORK_UDP_DATAGRAM_TTL_CONTINENT = 127, GNETWORK_UDP_DATAGRAM_TTL_GLOBAL = 255 } GNetworkUdpDatagramTtl;
An enumeration of possible time-to-live (ttl) values.
GNETWORK_UDP_DATAGRAM_TTL_DEFAULT | use the default kernel settings. |
GNETWORK_UDP_DATAGRAM_TTL_LOCAL_HOST | only survive on this host. |
GNETWORK_UDP_DATAGRAM_TTL_ONE_LINK | only survive across one link. |
GNETWORK_UDP_DATAGRAM_TTL_LOCAL_NET | only survive in the local network. |
GNETWORK_UDP_DATAGRAM_TTL_REGION | only survive in this region. |
GNETWORK_UDP_DATAGRAM_TTL_CONTINENT | only survive in this continent. |
GNETWORK_UDP_DATAGRAM_TTL_GLOBAL | broadcast across the internet. |
void gnetwork_udp_datagram_send_to (GNetworkUdpDatagram *udp, const gchar *host, guint16 port, gconstpointer data, glong length);
Sends data through udp to port on host. If length is -1, data is assumed to be 0-terminated, and the proper length will be calculated.
Subclasses should call this function to properly send data.
udp : | the datagram object. |
host : | the destination hostname, IP address, or NULL. |
port : | the destination port. |
data : | the data to send. |
length : | the length of data in bytes, or -1. |
Since 1.0
struct GNetworkUdpTarget;
An opaque structure used in the implementations-specific data arguments of the GNetworkDatagram signals. This structure contains no public fields and should be accessed and/or modified using the functions below.
GNetworkUdpTarget* gnetwork_udp_target_new (const gchar *host, guint16 port);
Creates a new GNetworkUdpTarget structure based on the information in host and port. The returned data should be freed with gnetwork_udp_target_free() when no longer needed.
host : | the IP address or hostname of the target. |
port : | the port number. |
Returns : | a newly allocated target structure. |
Since 1.0
void gnetwork_udp_target_set_host (GNetworkUdpTarget *target, const gchar *host);
Sets the destination hostname of target to host. The IP address of target will also be modified, to the address in host if it is a string representation of an IP address, and to all zeros if host is not.
target : | the message target to modify. |
host : | the new hostname, or NULL. |
Since 1.0
G_CONST_RETURN gchar* gnetwork_udp_target_get_host (const GNetworkUdpTarget *target);
Retrieves a copy of the hostname (in string form, e.g. "www.gnome.org") that target points to. If target does not know it's hostname, then NULL will be returned. The returned string should not be modifed or freed.
See also: gnetwork_udp_target_get_ip_address().
target : | the message target to examine. |
Returns : | a newly allocated string for the IP address of target. |
Since 1.0
void gnetwork_udp_target_set_port (GNetworkUdpTarget *target, guint16 port);
Sets the destination port of target to port. A port number of 0 allows the system to automatically select a port to use (for UDP clients only).
target : | the message target to modify. |
port : | the new port number. |
Since 1.0
guint16 gnetwork_udp_target_get_port (const GNetworkUdpTarget *target);
Retreives the port number that target points at.
target : | the message target to examine. |
Returns : | the target port. |
Since 1.0
void gnetwork_udp_target_set_ip_address (GNetworkUdpTarget *target, const GNetworkIpAddress *address);
Sets target to use address for it's destination. The host in target will be set to NULL as well.
target : | the message target to modify. |
address : | the new IP address. |
Since 1.0
G_CONST_RETURN GNetworkIpAddress* gnetwork_udp_target_get_ip_address (const GNetworkUdpTarget *target);
Returns a copy of the IP address that target points to. If target does not know it's IP address, NULL will be returned. The returned data should be freed with g_free() when no longer needed.
target : | the message target to examine. |
Returns : | a newly allocated GnetworkIpAddress for the IP address of target. |
Since 1.0
void gnetwork_udp_target_free (GNetworkUdpTarget *target);
Frees the memory used by target.
target : | the data to free. |
Since 1.0
GNetworkUdpTarget* gnetwork_udp_target_dup (const GNetworkUdpTarget *src);
Creates a copy of the data in src. The returned data should be freed with gnetwork_udp_target_free() when no longer needed.
src : | the message target to duplicate. |
Returns : | a copy of src. |
Since 1.0
"broadcast" gboolean : Read / Write / Construct
Whether or not to allow broadcasting through this socket.
Default value: FALSE
"interface" gchararray : Read / Write / Construct
The name of the interface to bind to (e.g. "eth0").
Default value: NULL
"interface-info" GNetworkInterfaceInfo : Read / Write
Information about the interface this socket is bound to.
"port" guint : Read / Write / Construct
The local port to bind to.
Allowed values: <= 65535
Default value: 0
"ttl" GNetworkUdpDatagramTtl : Read / Write / Construct
The distance messages sent through this datagram should travel.
Default value: GNETWORK_UDP_DATAGRAM_TTL_DEFAULT
<< GNetworkDatagram | GNetworkIpMulticast >> |