source: trunk/libtransmission/net.h @ 7133

Last change on this file since 7133 was 7133, checked in by charles, 13 years ago

(libT) define peer connections' sockets' so_sndbuf size in the tr_session struct.

  • Property svn:keywords set to Date Rev Author Id
File size: 3.1 KB
Line 
1/******************************************************************************
2 * $Id: net.h 7133 2008-11-21 16:32:55Z charles $
3 *
4 * Copyright (c) 2005-2008 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#ifdef WIN32
29 #include <inttypes.h>
30 #include <winsock2.h>
31 typedef int socklen_t;
32 typedef uint16_t tr_port_t;
33#elif defined( __BEOS__ )
34 #include <sys/socket.h>
35 #include <netinet/in.h>
36 typedef unsigned short tr_port_t;
37 typedef int socklen_t;
38#else
39 #include <sys/types.h>
40 #include <sys/socket.h>
41 #include <netinet/in.h>
42 #include <arpa/inet.h>
43 typedef in_port_t tr_port_t;
44#endif
45
46#ifdef WIN32
47 #define ECONNREFUSED WSAECONNREFUSED
48 #define ECONNRESET   WSAECONNRESET
49 #define EHOSTUNREACH WSAEHOSTUNREACH
50 #define EINPROGRESS  WSAEINPROGRESS
51 #define ENOTCONN     WSAENOTCONN
52 #define EWOULDBLOCK  WSAEWOULDBLOCK
53 #define sockerrno WSAGetLastError( )
54#else
55 #include <errno.h>
56 #define sockerrno errno
57#endif
58
59struct in_addr;
60struct sockaddr_in;
61struct tr_session;
62
63/***********************************************************************
64 * DNS resolution
65 **********************************************************************/
66int  tr_netResolve( const  char *,
67                    struct in_addr * );
68
69
70/***********************************************************************
71 * Sockets
72 **********************************************************************/
73int  tr_netOpenTCP( struct tr_handle     * session,
74                    const struct in_addr * addr,
75                    tr_port_t              port );
76
77int  tr_netBindTCP( int port );
78
79int  tr_netAccept( struct tr_handle  * session,
80                   int                 bound,
81                   struct in_addr    * setme_addr,
82                   tr_port_t         * setme_port );
83
84int  tr_netSetTOS( int s,
85                   int tos );
86
87void tr_netClose( int s );
88
89void tr_netNtop( const struct in_addr * addr,
90                 char *                 buf,
91                 int                    len );
92
93void tr_netInit( void );
94
95#endif /* _TR_NET_H_ */
Note: See TracBrowser for help on using the repository browser.