UNDatagramSocketHandle.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 
18 //#include "UNDatagramSocketHandle.ih"
19 
20 // Custom includes
21 #include <sys/socket.h>
22 #include <sys/types.h>
23 #include <sys/ioctl.h>
24 
25 #include <senf/Utils/Exception.hh>
26 
27 //#include "UNDatagramSocketHandle.mpp"
28 #define prefix_
29 //-/////////////////////////////////////////////////////////////////////////////////////////////////
30 
32 {
33  int sock = ::socket(PF_UNIX,SOCK_DGRAM | SOCK_CLOEXEC, 0);
34  if (sock < 0)
35  SENF_THROW_SYSTEM_EXCEPTION("Could not create socket(PF_UNIX,SOCK_DGRAM,0).");
36  fd(sock);
37 }
38 
40 {
41  init_client();
42  clientHandle().bind(address);
43 }
44 
45 //-/////////////////////////////////////////////////////////////////////////////////////////////////
46 #undef prefix_
47 //#include "UNDatagramSocketHandle.mpp"
48 
49 
50 // Local Variables:
51 // mode: c++
52 // fill-column: 100
53 // comment-column: 40
54 // c-file-style: "senf"
55 // indent-tabs-mode: nil
56 // ispell-local-dictionary: "american"
57 // compile-command: "scons -u test"
58 // End:
UNDatagramSocketHandle public header.
ClientSocketHandle< Policy > clientHandle() const
Get client handle for associated socket.
#define SENF_THROW_SYSTEM_EXCEPTION(desc)
Unix domain socket address.
Definition: UNAddressing.hh:41
int fd() const
Get file descriptor.
void init_client() const
Create unconnected client socket.
#define prefix_