source: trunk/libtransmission/net.h @ 1125

Last change on this file since 1125 was 920, checked in by joshe, 15 years ago

Merge nat-traversal branch to trunk.

  • Property svn:keywords set to Date Rev Author Id
File size: 2.8 KB
Line 
1/******************************************************************************
2 * $Id: net.h 920 2006-09-25 18:37:45Z livings124 $
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 sockets
41 **********************************************************************/
42#define tr_netOpenTCP( addr, port ) tr_netOpen( (addr), (port), SOCK_STREAM )
43#define tr_netOpenUDP( addr, port ) tr_netOpen( (addr), (port), SOCK_DGRAM )
44int  tr_netOpen    ( struct in_addr addr, in_port_t port, int type );
45int  tr_netMcastOpen( int port, struct in_addr addr );
46#define tr_netBindTCP( port ) tr_netBind( (port), SOCK_STREAM )
47#define tr_netBindUDP( port ) tr_netBind( (port), SOCK_DGRAM )
48int  tr_netBind    ( int port, int type );
49int  tr_netAccept  ( int s, struct in_addr *, in_port_t * );
50void tr_netClose   ( int s );
51
52#define TR_NET_BLOCK 0x80000000
53#define TR_NET_CLOSE 0x40000000
54int  tr_netSend    ( int s, uint8_t * buf, int size );
55#define tr_netRecv( s, buf, size ) tr_netRecvFrom( (s), (buf), (size), NULL )
56int  tr_netRecvFrom( int s, uint8_t * buf, int size, struct sockaddr_in * );
57
58void tr_netNtop( const struct in_addr * addr, char * buf, int len );
Note: See TracBrowser for help on using the repository browser.