4 * GDB RDP server stub - SH4 + ARM
6 * Copyright (c) 2009 Nathan Keynes.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
19 #ifndef lxdream_netutil_H
20 #define lxdream_netutil_H 1
22 #include <netinet/in.h>
23 #include <sys/socket.h>
26 typedef void *io_listener_t;
29 * Construct a server socket listening on the given interface and port. If port
30 * is 0, a dynamic port will be bound instead.
31 * This method does not register a listener.
32 * @return newly created socket fd, or -1 on failure.
34 int io_create_server_socket(const char *interface, int port );
37 * Callback invoked when data is available from the remote peer, or when the peer
38 * connects/disconnects.
40 * @param fd file descriptor of the connected socket
41 * @param data data supplied when the callback was registered
42 * @return TRUE to maintain the connection, FALSE to immediately disconnected + close.
44 typedef gboolean (*io_callback_t)( int fd, void *data );
47 * Register a TCP server socket listener on an already open (and listening)
48 * socket. The socket must not have been previously registered.
49 * @return NULL on failure, otherwise an io listener handle.
51 * Note: Implementation is platform specific
53 io_listener_t io_register_tcp_listener( int fd, io_callback_t callback, void *data, void (*dealloc)(void*) );
56 * Register an I/O listener on an open file descriptor. The fd must not have
57 * been previously registered.
58 * @return TRUE on success, FALSE on failure.
60 io_listener_t io_register_listener( int fd, io_callback_t callback, void *data, void (*dealloc)(void *) );
63 * Unregister a socket that was previously registered with the system. This
64 * does not close the socket, but will remove any callbacks associated with the socket.
66 void io_unregister_listener( io_listener_t handle );
68 #endif /* !lxdream_netutil_H */
.