source: trunk/libtransmission/net.h @ 1579

Last change on this file since 1579 was 1579, checked in by joshe, 16 years ago

Merge PEX branch, I hope this works.

  • Property svn:keywords set to Date Rev Author Id
File size: 3.0 KB
Line 
1/******************************************************************************
2 * $Id: net.h 1579 2007-03-23 08:28:01Z joshe $
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
26/***********************************************************************
27 * DNS resolution
28 **********************************************************************/
29int tr_netResolve( const char *, struct in_addr * );
30
31typedef struct tr_resolve_s tr_resolve_t;
32void           tr_netResolveThreadInit();
33void           tr_netResolveThreadClose();
34tr_resolve_t * tr_netResolveInit( const char * );
35tr_tristate_t  tr_netResolvePulse( tr_resolve_t *, struct in_addr * );
36void           tr_netResolveClose( tr_resolve_t * );
37
38
39/***********************************************************************
40 * TCP and UDP sockets
41 **********************************************************************/
42#define tr_netOpenTCP( addr, port, priority ) \
43    tr_netOpen( (addr), (port), SOCK_STREAM, (priority) )
44#define tr_netOpenUDP( addr, port, priority ) \
45    tr_netOpen( (addr), (port), SOCK_DGRAM, (priority) )
46int  tr_netOpen    ( struct in_addr addr, in_port_t port, int type,
47                     int priority );
48int  tr_netMcastOpen( int port, struct in_addr addr );
49#define tr_netBindTCP( port ) tr_netBind( (port), SOCK_STREAM )
50#define tr_netBindUDP( port ) tr_netBind( (port), SOCK_DGRAM )
51int  tr_netBind    ( int port, int type );
52int  tr_netAccept  ( int s, struct in_addr *, in_port_t * );
53void tr_netClose   ( int s );
54
55#define TR_NET_BLOCK 0x80000000
56#define TR_NET_CLOSE 0x40000000
57int  tr_netSend    ( int s, uint8_t * buf, int size );
58#define tr_netRecv( s, buf, size ) tr_netRecvFrom( (s), (buf), (size), NULL )
59int  tr_netRecvFrom( int s, uint8_t * buf, int size, struct sockaddr_in * );
60
61void tr_netNtop( const struct in_addr * addr, char * buf, int len );
62
63
64#define tr_addrcmp( aa, bb )    memcmp( ( void * )(aa), ( void * )(bb), 4)
Note: See TracBrowser for help on using the repository browser.