xc
TCP_UDP_Socket_base.h
1 // -*-c++-*-
2 //----------------------------------------------------------------------------
3 // XC program; finite element analysis code
4 // for structural analysis and design.
5 //
6 // Copyright (C) Luis C. Pérez Tato
7 //
8 // This program derives from OpenSees <http://opensees.berkeley.edu>
9 // developed by the «Pacific earthquake engineering research center».
10 //
11 // Except for the restrictions that may arise from the copyright
12 // of the original program (see copyright_opensees.txt)
13 // XC is free software: you can redistribute it and/or modify
14 // it under the terms of the GNU General Public License as published by
15 // the Free Software Foundation, either version 3 of the License, or
16 // (at your option) any later version.
17 //
18 // This software is distributed in the hope that it will be useful, but
19 // WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU General Public License for more details.
22 //
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program.
26 // If not, see <http://www.gnu.org/licenses/>.
27 //----------------------------------------------------------------------------
28 
29 #ifndef TCP_UDP_Socket_base_h
30 #define TCP_UDP_Socket_base_h
31 
32 #include "utility/actor/channel/Socket.h"
33 #include "utility/actor/channel/Channel.h"
34 
35 namespace XC {
37 //
41  {
42  protected:
43  socket_type sockfd;
44  int connectType;
45 
46  union
47  {
48  struct sockaddr addr;
49  struct sockaddr_in addr_in;
50  } my_Addr;
51  union
52  {
53  struct sockaddr addr;
54  struct sockaddr_in addr_in;
55  } other_Addr;
56 
57  socklen_type addrLength;
58  unsigned int myPort;
59 
60  bool checkEndianness;
61  bool endiannessProblem;
62 
63  unsigned int getPortNumber(void) const;
64  std::string getHostName(void) const;
65  virtual void checkForEndiannessProblem(void);
66  static int getHostAddress(const std::string &, char *);
67  static void int2a(unsigned int , char *, int *);
68  void setup(unsigned int , int );
69  public:
70  TCP_UDP_Socket_base(int connectType= 0, bool checkEndianness = false);
72  };
73 } // end of XC namespace
74 
75 
76 #endif
77 
78 
79 
80 
81 
82 
83 
84 
Definition: setup.py:1
static int getHostAddress(const std::string &, char *)
Is a static method to get the internet address of a host Takes machine name host & Returns 0 if o...
Definition: TCP_UDP_Socket_base.cc:143
static void int2a(unsigned int, char *, int *)
Static method to convert int to ascii.
Definition: TCP_UDP_Socket_base.cc:150
TCP_UDP_Socket_base(int connectType=0, bool checkEndianness=false)
Constructor to open a socket with my inet_addr and with a port number port.
Definition: TCP_UDP_Socket_base.cc:103
Channel is an abstract base class which defines the channel interface.
Definition: Channel.h:92
Open source finite element program for structural analysis.
Definition: ContinuaReprComponent.h:35
TCP_UDP_Socket_base is a sub-class of channel.
Definition: TCP_UDP_Socket_base.h:40