Search
lxdream.org :: lxdream/src/netutil.h :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/netutil.h
changeset 998:1754a8c6a9cf
next1021:848db285a184
author nkeynes
date Sat Apr 11 03:28:01 2009 +0000 (15 years ago)
permissions -rw-r--r--
last change Update sh4_translate_end_block_size() to have the correct backpatch sizes
(with recent changes there)
file annotate diff log raw
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/netutil.h Sat Apr 11 03:28:01 2009 +0000
1.3 @@ -0,0 +1,58 @@
1.4 +/**
1.5 + * $Id: netutil.h 1018 2009-03-19 12:29:06Z nkeynes $
1.6 + *
1.7 + * GDB RDP server stub - SH4 + ARM
1.8 + *
1.9 + * Copyright (c) 2009 Nathan Keynes.
1.10 + *
1.11 + * This program is free software; you can redistribute it and/or modify
1.12 + * it under the terms of the GNU General Public License as published by
1.13 + * the Free Software Foundation; either version 2 of the License, or
1.14 + * (at your option) any later version.
1.15 + *
1.16 + * This program is distributed in the hope that it will be useful,
1.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.19 + * GNU General Public License for more details.
1.20 + */
1.21 +
1.22 +#ifndef lxdream_netutil_H
1.23 +#define lxdream_netutil_H 1
1.24 +
1.25 +#include <netinet/in.h>
1.26 +#include "lxdream.h"
1.27 +
1.28 +/**
1.29 + * Construct a server socket listening on the given interface and port. If port
1.30 + * is 0, a dynamic port will be bound instead.
1.31 + * This method does not register a listener.
1.32 + * @return newly created socket fd, or -1 on failure.
1.33 + */
1.34 +int net_create_server_socket(const char *interface, int port );
1.35 +
1.36 +/**
1.37 + * Callback invoked when data is available from the remote peer, or when the peer
1.38 + * connects/disconnects.
1.39 + *
1.40 + * @param fd file descriptor of the connected socket
1.41 + * @param data data supplied when the callback was registered
1.42 + * @return TRUE to maintain the connection, FALSE to immediately disconnected + close.
1.43 + */
1.44 +typedef gboolean (*net_callback_t)( int fd, void *data );
1.45 +
1.46 +/**
1.47 + * Register a TCP server socket listener on an already open (and listening)
1.48 + * socket. The socket must not have been previously registered.
1.49 + * @return TRUE on success, FALSE on failure.
1.50 + *
1.51 + * Note: Implementation is platform specific
1.52 + */
1.53 +gboolean net_register_tcp_listener( int fd, net_callback_t callback, void *data, void (*dealloc)(void*) );
1.54 +
1.55 +/**
1.56 + * Unregister a socket that was previously registered with the system. This
1.57 + * does not close the socket, but will remove any callbacks associated with the socket.
1.58 + */
1.59 +gboolean net_unregister_listener( int fd );
1.60 +
1.61 +#endif /* !lxdream_netutil_H */
.