ConnectedUDPSocketHandle.cc
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
19 //#include "ConnectedUDPSocketHandle.ih"
20 
21 // Custom includes
22 #include <sys/types.h>
23 #include <sys/socket.h>
24 #include <sys/ioctl.h>
25 
26 #include <senf/Utils/Exception.hh>
27 
28 //#include "ConnectedUDPSocketHandle.mpp"
29 #define prefix_
30 //-/////////////////////////////////////////////////////////////////////////////////////////////////
31 
32 //-/////////////////////////////////////////////////////////////////////////////////////////////////
33 // senf::ConnectedUDPv4SocketProtocol
34 
36  const
37 {
38  int sock = ::socket(PF_INET,SOCK_DGRAM,0);
39  if (sock < 0)
40  SENF_THROW_SYSTEM_EXCEPTION("::socket(PF_INET,SOCK_DGRAM,0) failed.");
41  fd(sock);
42 }
43 
44 prefix_ void
46  const
47 {
48  init_client();
49  clientHandle().connect(address);
50 }
51 
52 //-/////////////////////////////////////////////////////////////////////////////////////////////////
53 // senf::ConnectedUDPv6SocketProtocol::
54 
56  const
57 {
58  int sock = ::socket(PF_INET6,SOCK_DGRAM,0);
59  if (sock < 0)
60  SENF_THROW_SYSTEM_EXCEPTION("::socket(PF_INET6,SOCK_DGRAM,0) failed.");
61  fd(sock);
62 }
63 
64 prefix_ void
66  const
67 {
68  init_client();
69  clientHandle().connect(address);
70 }
71 
72 //-/////////////////////////////////////////////////////////////////////////////////////////////////
73 #undef prefix_
74 //#include "ConnectedUDPSocketHandle.mpp"
75 
76 
77 // Local Variables:
78 // mode: c++
79 // fill-column: 100
80 // c-file-style: "senf"
81 // indent-tabs-mode: nil
82 // ispell-local-dictionary: "american"
83 // compile-command: "scons -u test"
84 // comment-column: 40
85 // End:
void init_client() const
Create unconnected client socket.
ClientSocketHandle< Policy > clientHandle() const
Get client handle for associated socket.
#define SENF_THROW_SYSTEM_EXCEPTION(desc)
IPv6 socket address.
int fd() const
Get file descriptor.
IPv4 socket address.
#define prefix_
UDPv4SocketHandle and UDPv6SocketHandle public header.
void init_client() const
Create unconnected client socket.