Simple Geolocalization and Course Transmission Protocol (SGCTP)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros Pages
transmit_tcp.hpp
Go to the documentation of this file.
1 // INDENTING (emacs/vi): -*- mode:c++; tab-width:2; c-basic-offset:2; intent-tabs-mode:nil; -*- ex: set tabstop=2 expandtab:
2 
3 /*
4  * Simple Geolocalization and Course Transmission Protocol (SGCTP)
5  * Copyright (C) 2014 Cedric Dufour <http://cedric.dufour.name>
6  *
7  * The Simple Geolocalization and Course Transmission Protocol (SGCTP) is
8  * free software:
9  * you can redistribute it and/or modify it under the terms of the GNU General
10  * Public License as published by the Free Software Foundation, Version 3.
11  *
12  * The Simple Geolocalization and Course Transmission Protocol (SGCTP) is
13  * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
14  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
15  * PARTICULAR PURPOSE.
16  *
17  * See the GNU General Public License for more details.
18  */
19 
20 #ifndef SGCTP_CTRANSMIT_TCP_HPP
21 #define SGCTP_CTRANSMIT_TCP_HPP
22 
23 // C
24 #include <stdint.h>
25 
26 // SGCTP
27 #include "sgctp/transmit.hpp"
28 
29 
30 // SGCTP namespace
31 namespace SGCTP
32 {
33 
35 
40  class CTransmit_TCP: public CTransmit
41  {
42 
43  //----------------------------------------------------------------------
44  // CONSTRUCTORS / DESTRUCTOR
45  //----------------------------------------------------------------------
46 
47  public:
49  : CTransmit()
50  {};
51  virtual ~CTransmit_TCP()
52  {};
53 
54 
55  //----------------------------------------------------------------------
56  // METHODS: CTransmit (implement/override)
57  //----------------------------------------------------------------------
58 
59  public:
60  virtual void setTimeout( int _iSocket,
61  double _fdTimeout );
62 
63  protected:
64  virtual int send( int _iSocket,
65  const void *_pBuffer,
66  int _iSize,
67  int _iFlags );
68 
69  virtual int recv( int _iSocket,
70  void *_pBuffer,
71  int _iSize,
72  int _iFlags );
73 
74  public:
76  {
77  return TRANSMIT_TCP;
78  };
79 
80  virtual int alloc();
81 
82  virtual int serialize( int _iSocket,
83  const CData &_roData );
84 
85  virtual int unserialize( int _iSocket,
86  CData *_poData,
87  int _iMaxSize = 0 );
88 
89  //----------------------------------------------------------------------
90  // METHODS
91  //----------------------------------------------------------------------
92 
93  public:
95 
99  int sendHandshake( int _iSocket );
101 
105  int recvHandshake( int _iSocket );
106 
107  };
108 
109 }
110 
111 #endif // SGCTP_CTRANSMIT_TCP_HPP
virtual void setTimeout(int _iSocket, double _fdTimeout)
Set the transmission (send/receive) timeout, in seconds.
virtual ETransmitType getTransmitType()
Return the transmission type.
virtual int recv(int _iSocket, void *_pBuffer, int _iSize, int _iFlags)
Receive data from the given descriptor.
int sendHandshake(int _iSocket)
Send the TCP handshake.
ETransmitType
Transmission types.
Definition: transmit.hpp:58
virtual int send(int _iSocket, const void *_pBuffer, int _iSize, int _iFlags)
Send data to the given descriptor.
virtual int alloc()
Allocate resources required for data transmission (un-/serialization)
SGCTP data container.
Definition: data.hpp:44
Generic transmission of SGCTP payload.
Definition: transmit.hpp:46
int recvHandshake(int _iSocket)
Receive the TCP handshake (and initialize internal resources: principal/payload)
virtual int serialize(int _iSocket, const CData &_roData)
Serialize the given SGCTP data to the given descriptor.
TCP transmission of SGCTP payload.
virtual int unserialize(int _iSocket, CData *_poData, int _iMaxSize=0)
Unserialize the SGCTP data from the given descriptor.