File: Socket.h

package info (click to toggle)
storm-lang 0.7.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 52,004 kB
  • sloc: ansic: 261,462; cpp: 140,405; sh: 14,891; perl: 9,846; python: 2,525; lisp: 2,504; asm: 860; makefile: 678; pascal: 70; java: 52; xml: 37; awk: 12
file content (54 lines) | stat: -rw-r--r-- 1,391 bytes parent folder | download | duplicates (2)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#pragma once
#include "Net.h"
#include "Address.h"
#include "Core/Timing.h"
#include "OS/Handle.h"

namespace storm {
	STORM_PKG(core.net);

	/**
	 * A generic socket.
	 *
	 * This socket encapsulates the generic parts of a socket, that is shared by TCP, UDP, and other
	 * protocols.
	 */
	class Socket : public Object {
		STORM_CLASS;
	public:
		// Create. Assumes the socket in 'handle' is set up for asynchronious operation.
		Socket(os::Handle handle, os::Thread attachedTo);

		// Copy ctor.
		Socket(const Socket &o);

		// Destroy.
		virtual ~Socket();

		// Close the socket. Calls 'close' on both the input and output streams.
		virtual void STORM_FN close();

		// To string.
		virtual void STORM_FN toS(StrBuf *to) const;

		// Get input buffer size in bytes.
		Nat STORM_FN inputBufferSize() const;

		// Set the input buffer size in bytes. The operating system may alter this value (eg. Linux doubles it).
		void STORM_ASSIGN inputBufferSize(Nat size);

		// Get the output buffer size in bytes.
		Nat STORM_FN outputBufferSize() const;

		// Set the output buffer size in bytes. The operating system may alter this value (eg. Linux doubles it).
		void STORM_ASSIGN outputBufferSize(Nat size);

	protected:
		// The handle for this socket.
		UNKNOWN(PTR_NOGC) os::Handle handle;

		// The thread the socket is associated with.
		UNKNOWN(PTR_NOGC) os::Thread attachedTo;
	};

}