GNet Network Library Reference Manual
<<< Previous Page | Home | Up | Next Page >>>

# mcast

## Name

mcast --

## Synopsis

    struct      GMcastSocket;
    GMcastSocket* gnet_mcast_socket_new         (void);
    GMcastSocket* gnet_mcast_socket_port_new    (gint port);
    GMcastSocket* gnet_mcast_socket_inetaddr_new
                                                (const GInetAddr *ia);
    void        gnet_mcast_socket_delete        (GMcastSocket *ms);
    void        gnet_mcast_socket_ref           (GMcastSocket *s);
    void        gnet_mcast_socket_unref         (GMcastSocket *s);
    gint        gnet_mcast_socket_join_group    (GMcastSocket *ms,
                                                 const GInetAddr *ia);
    gint        gnet_mcast_socket_leave_group   (GMcastSocket *ms,
                                                 const GInetAddr *ia);
    gint        gnet_mcast_socket_send          (GMcastSocket *ms,
                                                 const GUdpPacket *packet);
    gint        gnet_mcast_socket_receive       (GMcastSocket *ms,
                                                 GUdpPacket *packet);
    gboolean    gnet_mcast_socket_has_packet    (const GMcastSocket *s);
    gint        gnet_mcast_socket_is_loopback   (const GMcastSocket *ms);
    gint        gnet_mcast_socket_set_loopback  (GMcastSocket *ms,
                                                 gint b);
    #define     gnet_mcast_socket_to_udp_socket (MS)

## Description

## Details

### struct GMcastSocket

    struct GMcastSocket;

### gnet_mcast_socket_new ()

    GMcastSocket* gnet_mcast_socket_new         (void);

Create a new multicast socket with any available port. Use this constructor when you are creating a new group and the port number doesn't matter. If you want to receive packets from the group, you will have to join it next.

Returns : |

### gnet_mcast_socket_port_new ()

    GMcastSocket* gnet_mcast_socket_port_new    (gint port);

Create a new multicast socket with the given port. If you know the port of the group you will join, use this constructor. If you want to receive packets from the group, you will have to join it, using the full address, next.

`port` : |
Returns : |

### gnet_mcast_socket_inetaddr_new ()

    GMcastSocket* gnet_mcast_socket_inetaddr_new
                                                (const GInetAddr *ia);

Create a new multicast socket with the GInetAddr. If you know the GInetAddr of the group you will join, use this constructor. If you want to receive packets from the group, you will have to join it next.

`ia` : |
Returns : |

### gnet_mcast_socket_delete ()

    void        gnet_mcast_socket_delete        (GMcastSocket *ms);

Close and delete a multicast socket.

`ms` : |

### gnet_mcast_socket_ref ()

    void        gnet_mcast_socket_ref           (GMcastSocket *s);

Increment the reference counter of the GMcastSocket.

`s` : |

### gnet_mcast_socket_unref ()

    void        gnet_mcast_socket_unref         (GMcastSocket *s);

Remove a reference from the GMcastSocket. When reference count reaches 0, the socket is deleted.

`s` : |

### gnet_mcast_socket_join_group ()

    gint        gnet_mcast_socket_join_group    (GMcastSocket *ms,
                                                 const GInetAddr *ia);

Join the multicast group using the multicast socket. You should only join one group per socket.

`ms` : |
`ia` : |
Returns : |

### gnet_mcast_socket_leave_group ()

    gint        gnet_mcast_socket_leave_group   (GMcastSocket *ms,
                                                 const GInetAddr *ia);

Leave the mulitcast group.

`ms` : |
`ia` : |
Returns : |

### gnet_mcast_socket_send ()

    gint        gnet_mcast_socket_send          (GMcastSocket *ms,
                                                 const GUdpPacket *packet);

Send the packet using the multicast socket.

`ms` : |
`packet` : |
Returns : |

### gnet_mcast_socket_receive ()

    gint        gnet_mcast_socket_receive       (GMcastSocket *ms,
                                                 GUdpPacket *packet);

Receive a packet using the mcast socket.

`ms` : |
`packet` : |
Returns : |

### gnet_mcast_socket_has_packet ()

    gboolean    gnet_mcast_socket_has_packet    (const GMcastSocket *s);

Test if the socket has a receive packet.

`s` : |
Returns : |

### gnet_mcast_socket_is_loopback ()

    gint        gnet_mcast_socket_is_loopback   (const GMcastSocket *ms);

Check if the multicast socket has loopback enabled. If loopback is enabled, you receive all the packets you send. Most people don't want this.

`ms` : |
Returns : |

### gnet_mcast_socket_set_loopback ()

    gint        gnet_mcast_socket_set_loopback  (GMcastSocket *ms,
                                                 gint b);

Turn the loopback on or off. If loopback is on, when the process sends a packet, it will automatically be looped back to the host. If it is off, not only will this the process not receive datagrams it sends, other processes on the host will not receive its packets.

`ms` : |
`b` : |
Returns : |

### gnet_mcast_socket_to_udp_socket()

    #define     gnet_mcast_socket_to_udp_socket(MS)

Convert a multicast socket to a UDP socket (since a multicast socket is just a UDP socket with some special features).

`MS` : |

<<< Previous Page | Home | Up | Next Page >>>
udp | iochannel