libsocket
inetdgram.hpp
Go to the documentation of this file.
1 #ifndef LIBSOCKET_INETDGRAM_H_DD09F601418D47C8893DB605109E3E03
2 #define LIBSOCKET_INETDGRAM_H_DD09F601418D47C8893DB605109E3E03
3 
4 #include <string.h>
5 #include <iostream>
6 #include <string>
7 
8 #include "inetbase.hpp"
9 
10 #include <stdio.h>
11 #include <sys/socket.h>
12 #include <sys/types.h>
13 #include <unistd.h>
14 
20 /*
21  The committers of the libsocket project, all rights reserved
22  (c) 2012, dermesser <lbo@spheniscida.de>
23 
24  Redistribution and use in source and binary forms, with or without
25  modification, are permitted provided that the following conditions are met:
26 
27  1. Redistributions of source code must retain the above copyright notice,
28  this list of conditions and the following disclaimer.
29  2. Redistributions in binary form must reproduce the above copyright notice,
30  this list of conditions and the following disclaimer in the documentation
31  and/or other materials provided with the distribution.
32 
33  THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS “AS IS” AND ANY
34  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
35  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
36  DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
37  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
38  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
39  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
40  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
41  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
42  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43 
44 */
45 
46 namespace libsocket {
47 using std::string;
48 
60 class inet_dgram : public inet_socket {
61  public:
62  // I/O
63  // O
64  ssize_t sndto(const void* buf, size_t len, const char* dsthost,
65  const char* dstport, int sndto_flags = 0); // flags: sendto()
66  ssize_t sndto(const void* buf, size_t len, const string& dsthost,
67  const string& dstport, int sndto_flags = 0);
68 
69  ssize_t sndto(const string& buf, const string& dsthost,
70  const string& dstport, int sndto_flags = 0);
71 
72  // I
73  ssize_t rcvfrom(void* buf, size_t len, char* srchost, size_t hostlen,
74  char* srcport, size_t portlen, int rcvfrom_flags = 0,
75  bool numeric = false);
76  ssize_t rcvfrom(void* buf, size_t len, string& srchost, string& srcport,
77  int rcvfrom_flags = 0, bool numeric = false);
78 
79  ssize_t rcvfrom(string& buf, string& srchost, string& srcport,
80  int rcvfrom_flags = 0, bool numeric = false);
81 };
85 } // namespace libsocket
86 
87 #endif
Contains libsocket elements.
Definition: dgramclient.hpp:41
Internet-socket base class This class provides some fields for all internet sockets,...
Definition: inetbase.hpp:52
ssize_t rcvfrom(void *buf, size_t len, char *srchost, size_t hostlen, char *srcport, size_t portlen, int rcvfrom_flags=0, bool numeric=false)
Receives data from peer.
Definition: inetdgram.cpp:79
Base class for UDP/IP sockets.
Definition: inetdgram.hpp:60
ssize_t sndto(const void *buf, size_t len, const char *dsthost, const char *dstport, int sndto_flags=0)
Send data to UDP peer.
Definition: inetdgram.cpp:207