File: network.h

package info (click to toggle)
vdr-plugin-mp3 0.9.12-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 696 kB
  • ctags: 1,107
  • sloc: ansic: 12,353; makefile: 139; sh: 133
file content (58 lines) | stat: -rw-r--r-- 1,782 bytes parent folder | download | duplicates (11)
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
/*
 * MP3/MPlayer plugin to VDR (C++)
 *
 * (C) 2001-2005 Stefan Huelswitt <s.huelswitt@gmx.de>
 *
 * This code is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This code is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
 */

#ifndef ___NETWORK_H
#define ___NETWORK_H

#include <vdr/thread.h>
#include <vdr/ringbuffer.h>

class cRingBufferLinear;

// ----------------------------------------------------------------

class cNet : public cRingBufferLinear, cThread {
private:
  int fd;
  bool connected, netup;
  int deferedErrno;
  int rwTimeout, conTimeout;
  unsigned char lineBuff[4096];
  int count;
  //
  void Close(void);
  int RingRead(unsigned char *dest, int len);
  void CopyFromBuff(unsigned char *dest, int n);
protected:
  virtual void Action(void);
public:
  cNet(int size, int ConTimeoutMs, int RwTimeoutMs);
  ~cNet();
  bool Connect(const char *hostname, const int port);
  void Disconnect(void);
  bool Connected(void) { return connected; }
  int Gets(char *dest, int len);
  int Puts(char *dest);
  int Read(unsigned char *dest, int len);
  int Write(unsigned char *dest, int len);
  };

#endif //___NETWORK_H