summaryrefslogtreecommitdiffstats
blob: 2092c61fcd275d5b4c1959ea14435301a562240c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
 * Copyright (c) 2012 Yoann Blein
 * Licensed under the simplified BSD license.
 * See Documentation/Licenses/BSD-simplified.txt for more information.
 */

#pragma once

#include <Swiften/Base/boost_bsignals.h>
#include <Swiften/Base/SafeByteArray.h>

namespace Swift {
	class EventLoop;
	class HostAddress;
	class HostAddressPort;

	class UDPSocket {
		public:
			typedef boost::shared_ptr<UDPSocket> ref;

			virtual ~UDPSocket() {}

			virtual int bind(const HostAddressPort& addr) = 0;
			virtual int bindOnAvailablePort(const HostAddress& addr) = 0;
			virtual void listen() = 0;
			virtual void connect(const HostAddressPort& address) = 0;
			virtual void connectToFirstIncoming() = 0;
			virtual void send(const SafeByteArray& data) = 0;
			virtual void close() = 0;
			virtual HostAddressPort getLocalAddress() const = 0;
			virtual HostAddressPort getRemoteAddress() const = 0;

		public:
			boost::signal<void (boost::shared_ptr<SafeByteArray>)> onDataRead;
			boost::signal<void ()> onConnected;
	};
}