Search
lxdream.org :: lxdream/src/netutil.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/netutil.h
changeset 998:1754a8c6a9cf
next1021:848db285a184
author nkeynes
date Tue Mar 24 11:15:57 2009 +0000 (15 years ago)
permissions -rw-r--r--
last change Add preliminary implementation of the GDB remote debugging server - attaches to
either or both the SH4 and ARM
file annotate diff log raw
nkeynes@998
     1
/**
nkeynes@998
     2
 * $Id: netutil.h 1018 2009-03-19 12:29:06Z nkeynes $
nkeynes@998
     3
 * 
nkeynes@998
     4
 * GDB RDP server stub - SH4 + ARM
nkeynes@998
     5
 *
nkeynes@998
     6
 * Copyright (c) 2009 Nathan Keynes.
nkeynes@998
     7
 *
nkeynes@998
     8
 * This program is free software; you can redistribute it and/or modify
nkeynes@998
     9
 * it under the terms of the GNU General Public License as published by
nkeynes@998
    10
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@998
    11
 * (at your option) any later version.
nkeynes@998
    12
 *
nkeynes@998
    13
 * This program is distributed in the hope that it will be useful,
nkeynes@998
    14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@998
    15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@998
    16
 * GNU General Public License for more details.
nkeynes@998
    17
 */
nkeynes@998
    18
nkeynes@998
    19
#ifndef lxdream_netutil_H
nkeynes@998
    20
#define lxdream_netutil_H 1
nkeynes@998
    21
nkeynes@998
    22
#include <netinet/in.h>
nkeynes@998
    23
#include "lxdream.h"
nkeynes@998
    24
nkeynes@998
    25
/**
nkeynes@998
    26
 * Construct a server socket listening on the given interface and port. If port
nkeynes@998
    27
 * is 0, a dynamic port will be bound instead. 
nkeynes@998
    28
 * This method does not register a listener.
nkeynes@998
    29
 * @return newly created socket fd, or -1 on failure.
nkeynes@998
    30
 */ 
nkeynes@998
    31
int net_create_server_socket(const char *interface, int port );
nkeynes@998
    32
nkeynes@998
    33
/**
nkeynes@998
    34
 * Callback invoked when data is available from the remote peer, or when the peer
nkeynes@998
    35
 * connects/disconnects.
nkeynes@998
    36
 * 
nkeynes@998
    37
 * @param fd     file descriptor of the connected socket
nkeynes@998
    38
 * @param data   data supplied when the callback was registered
nkeynes@998
    39
 * @return TRUE to maintain the connection, FALSE to immediately disconnected + close.
nkeynes@998
    40
 */
nkeynes@998
    41
typedef gboolean (*net_callback_t)( int fd, void *data );
nkeynes@998
    42
nkeynes@998
    43
/**
nkeynes@998
    44
 * Register a TCP server socket listener on an already open (and listening) 
nkeynes@998
    45
 * socket. The socket must not have been previously registered.
nkeynes@998
    46
 * @return TRUE on success, FALSE on failure.
nkeynes@998
    47
 * 
nkeynes@998
    48
 * Note: Implementation is platform specific
nkeynes@998
    49
 */ 
nkeynes@998
    50
gboolean net_register_tcp_listener( int fd, net_callback_t callback, void *data, void (*dealloc)(void*) );
nkeynes@998
    51
nkeynes@998
    52
/**
nkeynes@998
    53
 * Unregister a socket that was previously registered with the system. This
nkeynes@998
    54
 * does not close the socket, but will remove any callbacks associated with the socket.
nkeynes@998
    55
 */ 
nkeynes@998
    56
gboolean net_unregister_listener( int fd );
nkeynes@998
    57
nkeynes@998
    58
#endif /* !lxdream_netutil_H */
.