Search
lxdream.org :: lxdream/src/netutil.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/netutil.h
changeset 1021:848db285a184
prev998:1754a8c6a9cf
author nkeynes
date Wed Jun 03 11:37:10 2009 +0000 (12 years ago)
permissions -rw-r--r--
last change Add missing svn:keywords property
view annotate diff log raw
     1 /**
     2  * $Id$
     3  * 
     4  * GDB RDP server stub - SH4 + ARM
     5  *
     6  * Copyright (c) 2009 Nathan Keynes.
     7  *
     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.
    12  *
    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.
    17  */
    19 #ifndef lxdream_netutil_H
    20 #define lxdream_netutil_H 1
    22 #include <netinet/in.h>
    23 #include "lxdream.h"
    25 /**
    26  * Construct a server socket listening on the given interface and port. If port
    27  * is 0, a dynamic port will be bound instead. 
    28  * This method does not register a listener.
    29  * @return newly created socket fd, or -1 on failure.
    30  */ 
    31 int net_create_server_socket(const char *interface, int port );
    33 /**
    34  * Callback invoked when data is available from the remote peer, or when the peer
    35  * connects/disconnects.
    36  * 
    37  * @param fd     file descriptor of the connected socket
    38  * @param data   data supplied when the callback was registered
    39  * @return TRUE to maintain the connection, FALSE to immediately disconnected + close.
    40  */
    41 typedef gboolean (*net_callback_t)( int fd, void *data );
    43 /**
    44  * Register a TCP server socket listener on an already open (and listening) 
    45  * socket. The socket must not have been previously registered.
    46  * @return TRUE on success, FALSE on failure.
    47  * 
    48  * Note: Implementation is platform specific
    49  */ 
    50 gboolean net_register_tcp_listener( int fd, net_callback_t callback, void *data, void (*dealloc)(void*) );
    52 /**
    53  * Unregister a socket that was previously registered with the system. This
    54  * does not close the socket, but will remove any callbacks associated with the socket.
    55  */ 
    56 gboolean net_unregister_listener( int fd );
    58 #endif /* !lxdream_netutil_H */
.