libsocket
inetclientdgram.hpp
Go to the documentation of this file.
1 #ifndef LIBSOCKET_INETDGRAMCLIENT_H_1E7B8B3247594112BB2CEB2895E916E4
2 #define LIBSOCKET_INETDGRAMCLIENT_H_1E7B8B3247594112BB2CEB2895E916E4
3 
4 #include <sys/socket.h>
5 #include <sys/types.h>
6 #include <string>
7 
8 #include "dgramclient.hpp"
9 #include "inetdgram.hpp"
10 
16 /*
17  The committers of the libsocket project, all rights reserved
18  (c) 2012, dermesser <lbo@spheniscida.de>
19 
20  Redistribution and use in source and binary forms, with or without
21  modification, are permitted provided that the following conditions are met:
22 
23  1. Redistributions of source code must retain the above copyright notice,
24  this list of conditions and the following disclaimer.
25  2. Redistributions in binary form must reproduce the above copyright notice,
26  this list of conditions and the following disclaimer in the documentation
27  and/or other materials provided with the distribution.
28 
29  THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS “AS IS” AND ANY
30  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
31  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
32  DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
33  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
34  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
35  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
36  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
38  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 
40 */
41 namespace libsocket {
42 using std::string;
43 
56  public:
57  // Only create socket
58  inet_dgram_client(int proto_osi3, int flags = 0); // Flags: socket()
59  // Create socket and connect it
60  inet_dgram_client(const char* dsthost, const char* dstport, int proto_osi3,
61  int flags = 0); // Flags: socket()
62  inet_dgram_client(const string& dsthost, const string& dstport,
63  int proto_osi3, int flags = 0);
64 
65  // actions
66  // connect/reconnect
67  void connect(const char* dsthost, const char* dstport);
68  void connect(const string& dsthost, const string& dstport);
69 
70  void deconnect(void);
71 
72  private:
73  void setup(int proto_osi3, int flags = 0);
74  void setup(const char* dsthost, const char* dstport, int proto_osi3,
75  int flags = 0);
76  void setup(const string& dsthost, const string& dstport, int proto_osi3,
77  int flags = 0);
78 };
82 } // namespace libsocket
83 #endif
Contains libsocket elements.
Definition: dgramclient.hpp:41
Using UDP/IP easy as never before. Class for connectable datagram sockets in the INET domain....
Represents a generic "client" datagram socket, i.e. a datagram socket which can be connected.
Definition: dgramclient.hpp:53
void setup(int proto_osi3, int flags=0)
Set up normal datagram socket (connectable). [NOT FOR EXTERNAL USE].
void connect(const char *dsthost, const char *dstport)
Connect datagram socket.
Base class for UDP/IP sockets.
Definition: inetdgram.hpp:60
inet_dgram_client(int proto_osi3, int flags=0)
Create normal datagram socket (connectable).