activemq-cpp-3.8.2
DatagramPacket.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef _DECAF_NET_DATAGRAMPACKET_H_
19 #define _DECAF_NET_DATAGRAMPACKET_H_
20 
21 #include <decaf/util/Config.h>
22 
23 #include <decaf/net/Inet4Address.h>
25 
29 
31 
32 namespace decaf {
33 namespace net {
34 
44  private:
45 
46  unsigned char* buffer;
47  int size;
48  int offset;
49  int length;
50 
51  InetAddress* address;
52  int port;
53 
54  mutable decaf::util::concurrent::Mutex mutex;
55 
56  private:
57 
59  DatagramPacket& operator= ( const DatagramPacket& );
60 
61  public:
62 
76  DatagramPacket( unsigned char* bytes, int size, int length );
77 
94  DatagramPacket( unsigned char* bytes, int size, int offset, int length );
95 
117  DatagramPacket( unsigned char* bytes, int size, int offset, int length, const InetAddress& address, int port );
118 
137  DatagramPacket( unsigned char* bytes, int size, int length, const InetAddress& address, int port );
138 
155  DatagramPacket( unsigned char* bytes, int size, int length, const SocketAddress& address );
156 
175  DatagramPacket( unsigned char* bytes, int size, int offset, int length, const SocketAddress& address );
176 
177  virtual ~DatagramPacket();
178 
179  public:
180 
184  InetAddress* getAddress() const;
185 
192  void setAddress( const InetAddress& address );
193 
201 
211  void setSocketAddress( const SocketAddress& address );
212 
216  int getPort() const;
217 
226  void setPort( int port );
227 
231  int getOffset() const;
232 
242  void setOffset( int offset );
243 
247  int getLength() const;
248 
260  void setLength( int length );
261 
266  unsigned char* getData() const;
267 
271  int getSize() const;
272 
284  void setData( unsigned char* buffer, int size );
285 
301  void setData( unsigned char* buffer, int size, int offset, int length );
302 
303  };
304 
305 }}
306 
307 #endif /* _DECAF_NET_DATAGRAMPACKET_H_ */
Mutex object that offers recursive support on all platforms as well as providing the ability to use t...
Definition: Mutex.h:39
void setSocketAddress(const SocketAddress &address)
Sets the SocketAddress (usually IP address + port number) of the remote host to which this datagram i...
void setPort(int port)
Sets the port number on the remote host to which this datagram is being sent.
SocketAddress * getSocketAddress() const
Gets the SocketAddress (usually IP address + port number) of the remote host that this packet is bein...
void setAddress(const InetAddress &address)
Sets the IP address of the machine to which this datagram is being sent.
Represents an IP address.
Definition: InetAddress.h:33
void setOffset(int offset)
Sets the offset into the data buffer where data to sent is to be read from or where the data that is ...
void setLength(int length)
Set the length for this packet.
unsigned char * getData() const
void setData(unsigned char *buffer, int size)
Set the data buffer for this packet.
Class that represents a single datagram packet.
Definition: DatagramPacket.h:43
Base class for protocol specific Socket addresses.
Definition: SocketAddress.h:32
InetAddress * getAddress() const
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: AprPool.h:25