source: trunk/libtransmission/net.h @ 2573

Last change on this file since 2573 was 2573, checked in by charles, 14 years ago

continue whittling away at internal.h to reduce the global #include dependencies

  • Property svn:keywords set to Date Rev Author Id
File size: 3.0 KB
Line 
1/******************************************************************************
2 * $Id: net.h 2573 2007-07-31 14:26:44Z charles $
3 *
4 * Copyright (c) 2005-2006 Transmission authors and contributors
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 *****************************************************************************/
24
25#ifndef _TR_NET_H_
26#define _TR_NET_H_
27
28#if defined(BEOS_NETSERVER) || defined(__MINGW__)
29#include <stdint.h>
30typedef uint16_t tr_port_t;
31#else
32#include <arpa/inet.h>
33typedef in_port_t tr_port_t;
34#endif
35
36struct in_addr;
37struct sockaddr_in;
38
39/***********************************************************************
40 * DNS resolution
41 **********************************************************************/
42int tr_netResolve( const char *, struct in_addr * );
43
44typedef struct tr_resolve_s tr_resolve_t;
45void           tr_netResolveThreadInit();
46void           tr_netResolveThreadClose();
47tr_resolve_t * tr_netResolveInit( const char * address );
48tr_tristate_t  tr_netResolvePulse( tr_resolve_t *, struct in_addr * );
49void           tr_netResolveClose( tr_resolve_t * );
50
51
52/***********************************************************************
53 * TCP and UDP sockets
54 **********************************************************************/
55int  tr_netOpenTCP ( const struct in_addr * addr, tr_port_t port, int priority );
56int  tr_netOpenUDP ( const struct in_addr * addr, tr_port_t port, int priority );
57int  tr_netMcastOpen( int port, const struct in_addr * addr );
58int  tr_netBindTCP ( int port );
59int  tr_netBindUDP ( int port );
60int  tr_netAccept  ( int s, struct in_addr *, tr_port_t * );
61void tr_netClose   ( int s );
62
63#define TR_NET_BLOCK 0x80000000
64#define TR_NET_CLOSE 0x40000000
65int  tr_netSend    ( int s, const void * buf, int size );
66#define tr_netRecv( s, buf, size ) tr_netRecvFrom( (s), (buf), (size), NULL )
67int  tr_netRecvFrom( int s, uint8_t * buf, int size, struct sockaddr_in * );
68
69void tr_netNtop( const struct in_addr * addr, char * buf, int len );
70
71
72#define tr_addrcmp( aa, bb )    memcmp( ( void * )(aa), ( void * )(bb), 4)
73
74#endif /* _TR_NET_H_ */
Note: See TracBrowser for help on using the repository browser.