1 // -*- c++ -*- 2 //------------------------------------------------------------------------------ 3 // ConUDPSocket.h 4 //------------------------------------------------------------------------------ 5 // Copyright (C) 1997-2002 Vladislav Grinchenko 6 // 7 // This library is free software; you can redistribute it and/or 8 // modify it under the terms of the GNU Library General Public 9 // License as published by the Free Software Foundation; either 10 // version 2 of the License, or (at your option) any later version. 11 //------------------------------------------------------------------------------ 12 #ifndef CONUDP_SOCKET_H 13 #define CONUDP_SOCKET_H 14 15 #include "assa/UDPSocket.h" 16 17 namespace ASSA { 18 19 /** @file ConUDPSocket.h 20 21 Encapsulation of a connected UDP socket. 22 */ 23 24 class ConUDPSocket : public UDPSocket { 25 public: 26 /// Constructor ConUDPSocket()27 ConUDPSocket () : UDPSocket() { 28 char self[] = "ConUDPSocket::ConUDPSocket"; trace(self); 29 } 30 31 /// Destructor ~ConUDPSocket()32 virtual ~ConUDPSocket () { 33 char self[] = "ConUDPSocket::~ConUDPSocket"; trace(self); 34 } 35 36 /** Connect socket to the peer. 37 * @param peer_addr_ peer address 38 */ 39 bool connect (const Address& peer_addr_); 40 41 /// Unconnect connected socket 42 void unconnect (); 43 44 /** Read specified number of bytes off the socket. 45 * This function cannot be moved up in class hierarchy 46 * because IPv4 read() is *very* different from UDP read (one 47 * time shot). 48 * 49 * @param buf_ buffer to save received data into 50 * @param size_ expected packet size 51 * @return number of bytes read or -1 on error, indicating 52 * the reason in errno. Packets of 0 size are possible. 53 */ 54 int read (char* buf_, const unsigned int size_); 55 56 /** Perform blocking write by writing packet of specified size. 57 * 58 * @param buf_ buffer to send 59 * @param size_ packet size 60 */ 61 int write (const char* buf_ = NULL, const unsigned int size_ = 0); 62 in_avail()63 virtual int in_avail () const { return 0; } 64 }; 65 66 } // end namespace ASSA 67 68 #endif // CONUDP_SOCKET_H 69 70 71 72