File: ConUDPSocket.h

package info (click to toggle)
libassa 3.5.1-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 3,268 kB
  • sloc: cpp: 15,703; sh: 12,083; makefile: 379; perl: 51
file content (71 lines) | stat: -rw-r--r-- 2,013 bytes parent folder | download | duplicates (9)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// -*- c++ -*-
//------------------------------------------------------------------------------
//                           ConUDPSocket.h
//------------------------------------------------------------------------------
//  Copyright (C) 1997-2002  Vladislav Grinchenko 
//
//  This library is free software; you can redistribute it and/or
//  modify it under the terms of the GNU Library General Public
//  License as published by the Free Software Foundation; either
//  version 2 of the License, or (at your option) any later version.
//------------------------------------------------------------------------------
#ifndef CONUDP_SOCKET_H
#define CONUDP_SOCKET_H

#include "assa/UDPSocket.h"

namespace ASSA {

/** @file ConUDPSocket.h

    Encapsulation of a connected UDP socket.
*/

class ConUDPSocket : public UDPSocket {
public:
	/// Constructor
	ConUDPSocket () : UDPSocket() {
		char self[] = "ConUDPSocket::ConUDPSocket"; trace(self);
	}
    
	/// Destructor
	virtual ~ConUDPSocket () {
		char self[] = "ConUDPSocket::~ConUDPSocket"; trace(self);
	} 

	/** Connect socket to the peer.
	 *  @param peer_addr_ peer address
	 */
	bool connect (const Address& peer_addr_);

	/// Unconnect connected socket
	void unconnect ();

	/** Read specified number of bytes off the socket.
	 *  This function cannot be moved up in class hierarchy
	 *  because IPv4 read() is *very* different from UDP read (one
	 *  time shot).
	 *
	 *  @param buf_ buffer to save received data into
	 *  @param size_ expected packet size
	 *  @return number of bytes read or -1 on error, indicating 
	 *          the reason in errno. Packets of 0 size are possible.
	 */
	int read (char* buf_, const unsigned int size_);
	
	/** Perform blocking write by writing packet of specified size.
	 *
	 *  @param buf_ buffer to send
	 *  @param size_ packet size
	 */
	int write (const char* buf_ = NULL, const unsigned int size_ = 0);

	virtual int in_avail () const { return 0; }
};

} // end namespace ASSA

#endif // CONUDP_SOCKET_H