nkeynes@998: /** nkeynes@1021: * $Id$ nkeynes@998: * nkeynes@998: * GDB RDP server stub - SH4 + ARM nkeynes@998: * nkeynes@998: * Copyright (c) 2009 Nathan Keynes. nkeynes@998: * nkeynes@998: * This program is free software; you can redistribute it and/or modify nkeynes@998: * it under the terms of the GNU General Public License as published by nkeynes@998: * the Free Software Foundation; either version 2 of the License, or nkeynes@998: * (at your option) any later version. nkeynes@998: * nkeynes@998: * This program is distributed in the hope that it will be useful, nkeynes@998: * but WITHOUT ANY WARRANTY; without even the implied warranty of nkeynes@998: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the nkeynes@998: * GNU General Public License for more details. nkeynes@998: */ nkeynes@998: nkeynes@998: #ifndef lxdream_netutil_H nkeynes@998: #define lxdream_netutil_H 1 nkeynes@998: nkeynes@998: #include nkeynes@1204: #include nkeynes@998: #include "lxdream.h" nkeynes@998: nkeynes@1077: typedef void *io_listener_t; nkeynes@1077: nkeynes@998: /** nkeynes@998: * Construct a server socket listening on the given interface and port. If port nkeynes@998: * is 0, a dynamic port will be bound instead. nkeynes@998: * This method does not register a listener. nkeynes@998: * @return newly created socket fd, or -1 on failure. nkeynes@998: */ nkeynes@1077: int io_create_server_socket(const char *interface, int port ); nkeynes@998: nkeynes@998: /** nkeynes@998: * Callback invoked when data is available from the remote peer, or when the peer nkeynes@998: * connects/disconnects. nkeynes@998: * nkeynes@998: * @param fd file descriptor of the connected socket nkeynes@998: * @param data data supplied when the callback was registered nkeynes@998: * @return TRUE to maintain the connection, FALSE to immediately disconnected + close. nkeynes@998: */ nkeynes@1077: typedef gboolean (*io_callback_t)( int fd, void *data ); nkeynes@998: nkeynes@998: /** nkeynes@998: * Register a TCP server socket listener on an already open (and listening) nkeynes@998: * socket. The socket must not have been previously registered. nkeynes@1077: * @return NULL on failure, otherwise an io listener handle. nkeynes@998: * nkeynes@998: * Note: Implementation is platform specific nkeynes@998: */ nkeynes@1077: io_listener_t io_register_tcp_listener( int fd, io_callback_t callback, void *data, void (*dealloc)(void*) ); nkeynes@1077: nkeynes@1077: /** nkeynes@1077: * Register an I/O listener on an open file descriptor. The fd must not have nkeynes@1077: * been previously registered. nkeynes@1077: * @return TRUE on success, FALSE on failure. nkeynes@1077: */ nkeynes@1077: io_listener_t io_register_listener( int fd, io_callback_t callback, void *data, void (*dealloc)(void *) ); nkeynes@998: nkeynes@998: /** nkeynes@998: * Unregister a socket that was previously registered with the system. This nkeynes@998: * does not close the socket, but will remove any callbacks associated with the socket. nkeynes@998: */ nkeynes@1077: void io_unregister_listener( io_listener_t handle ); nkeynes@998: nkeynes@998: #endif /* !lxdream_netutil_H */