Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / lib / tt / lib / mp / mp_stream_socket.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /*%%  (c) Copyright 1993, 1994 Hewlett-Packard Company                   */
24 /*%%  (c) Copyright 1993, 1994 International Business Machines Corp.     */
25 /*%%  (c) Copyright 1993, 1994 Sun Microsystems, Inc.                    */
26 /*%%  (c) Copyright 1993, 1994 Novell, Inc.                              */
27 /*%%  $XConsortium: mp_stream_socket.h /main/3 1995/10/23 10:29:57 rswiston $                                                    */
28 /* 
29  * mp_stream_socket.h
30  * 
31  * Copyright (c) 1990 by Sun Microsystems, Inc.
32  * 
33  * This file implements the _Tt_stream_socket which is an object used to
34  * deal with TCP sockets. The methods for this object handle creation,
35  * destruction and communicating over TCP sockets. Note that the
36  * implementation of stream sockets is tailored specifically to the use
37  * of sockets by the MP as a signalling mechanism. The methods here are
38  * not intended to be a general C++ wrapper for sockets.
39  */
40 #ifndef MP_STREAM_SOCKET_H
41 #define MP_STREAM_SOCKET_H
42 #include <sys/types.h>
43 #include <tt_options.h>
44
45 #ifdef OPT_TLI
46 #       include <tiuser.h>
47 #endif
48 #include <netinet/in.h>
49 #include <util/tt_object.h>
50 #include <util/tt_ptr.h>
51 #include <util/tt_host_utils.h>
52
53 class _Tt_stream_socket : public _Tt_object {
54       public:
55         _Tt_stream_socket();
56         _Tt_stream_socket(_Tt_host_ptr &host, int port);
57         virtual ~_Tt_stream_socket();
58         int             init(int init_as_source);
59         int             send(char *msg, int len);
60         int             recv(char *msg, int len);
61         int             port();
62         int             fd();
63         int             sock();
64         int             read_would_block();
65       private:
66         int             accept();
67         int             _is_source;
68         int             _msgsock;
69         int             _sock;
70         _Tt_host_ptr    _host;
71         sockaddr_in     _hostaddr;
72 #ifdef OPT_TLI
73         int             _port;
74         t_call          *_srequest;
75 #endif                          /* OPT_TLI */
76 };
77
78
79 #endif                          /* MP_STREAM_SOCKET_H */