summaryrefslogtreecommitdiff
path: root/socket/socket.h
diff options
context:
space:
mode:
authorYouness Alaoui <kakaroto@kakaroto.(none)>2008-10-06 17:45:13 -0400
committerYouness Alaoui <kakaroto@kakaroto.(none)>2008-10-06 17:45:13 -0400
commita972e82678602a0d1fee62090b79c3b1eac786c8 (patch)
treec94c82e498d4f81a7b51c871894e9113111d7f28 /socket/socket.h
parent4459912bbea7dce6dd5cf9009dd07d7f8097d600 (diff)
downloadlibnice-a972e82678602a0d1fee62090b79c3b1eac786c8.tar.gz
new NiceSocket API
Diffstat (limited to 'socket/socket.h')
-rw-r--r--socket/socket.h58
1 files changed, 33 insertions, 25 deletions
diff --git a/socket/socket.h b/socket/socket.h
index 466db0c..e93669f 100644
--- a/socket/socket.h
+++ b/socket/socket.h
@@ -35,71 +35,79 @@
* file under either the MPL or the LGPL.
*/
-#ifndef _UDP_H
-#define _UDP_H
+#ifndef _SOCKET_H
+#define _SOCKET_H
#include "address.h"
G_BEGIN_DECLS
-typedef struct _NiceUDPSocket NiceUDPSocket;
+typedef struct _NiceSocket NiceSocket;
-struct _NiceUDPSocket
+struct _NiceSocket
{
NiceAddress addr;
guint fileno;
- gint (*recv) (NiceUDPSocket *sock, NiceAddress *from, guint len,
+ gint (*recv) (NiceSocket *sock, NiceAddress *from, guint len,
gchar *buf);
- gboolean (*send) (NiceUDPSocket *sock, const NiceAddress *to, guint len,
+ gboolean (*send) (NiceSocket *sock, const NiceAddress *to, guint len,
const gchar *buf);
- void (*close) (NiceUDPSocket *sock);
+ void (*close) (NiceSocket *sock);
void *priv;
};
-typedef struct _NiceUDPSocketManager NiceUDPSocketFactory;
+typedef struct _NiceSocketFactory NiceSocketFactory;
-struct _NiceUDPSocketManager
+struct _NiceSocketFactory
{
- gboolean (*init) (NiceUDPSocketFactory *man, NiceUDPSocket *sock,
+ gboolean (*init) (NiceSocketFactory *man, NiceSocket *sock,
NiceAddress *sin);
- void (*close) (NiceUDPSocketFactory *man);
+ void (*close) (NiceSocketFactory *man);
void *priv;
};
+typedef enum {
+ NICE_SOCKET_FACTORY_UDP_BSD,
+ NICE_SOCKET_FACTORY_UDP_RELAY,
+} NiceSocketFactoryType;
+
+G_GNUC_WARN_UNUSED_RESULT
+NiceSocketFactory *
+nice_socket_factory_new (NiceSocketFactoryType type);
+
+void
+nice_socket_factory_free (NiceSocketFactory *man);
+
/**
* If sin is not NULL, the new socket will be bound to that IP address/port.
* If sin->sin_port is 0, a port will be assigned at random. In all cases, the
* address bound to will be set in sock->addr.
*/
G_GNUC_WARN_UNUSED_RESULT
-gboolean
-nice_udp_socket_factory_make (
- NiceUDPSocketFactory *man,
- NiceUDPSocket *sock,
- NiceAddress *addr);
-
-void
-nice_udp_socket_factory_close (NiceUDPSocketFactory *man);
+NiceSocket *
+nice_socket_new (
+ NiceSocketFactory *man,
+ NiceAddress *adddr);
G_GNUC_WARN_UNUSED_RESULT
gint
-nice_udp_socket_recv (
- NiceUDPSocket *sock,
+nice_socket_recv (
+ NiceSocket *sock,
NiceAddress *from,
guint len,
gchar *buf);
void
-nice_udp_socket_send (
- NiceUDPSocket *sock,
+nice_socket_send (
+ NiceSocket *sock,
const NiceAddress *to,
guint len,
const gchar *buf);
void
-nice_udp_socket_close (NiceUDPSocket *sock);
+nice_socket_free (NiceSocket *sock);
G_END_DECLS
-#endif /* _UDP_H */
+#endif /* _SOCKET_H */