Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
CScommClient.hh
1 /*
2 This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4 Copyright (C) 2003-2009 (see file CONTACT for details)
5 Multimediale Systeme der Informationsverarbeitung
6 Institut fuer Informatik
7 Christian-Albrechts-Universitaet Kiel
8 
9 
10 BIAS is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14 
15 BIAS is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19 
20 You should have received a copy of the GNU Lesser General Public License
21 along with BIAS; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24 
25 #ifndef __BIASCScommClient__
26 #define __BIASCScommClient__
27 
28 #include "CScommBase.hh"
29 
30 
31 namespace BIAS {
32  /**
33  @class CScommClient
34  @ingroup network
35  @brief class for sending/receiving data between clients and servers
36 
37  Only registered msgs will be accepted at the server side,
38  similar the client will accept only registered msgs from the server too.
39  The client needs to know the hostname of the server.
40  Usage: <br>
41 
42  -# Konstruktor: CScommClient client;
43 
44  -# Register msgs: client.RegisterMsg(msgName, BIAS::CS_FLOAT, 3);
45 
46  -# connect server: client.ConnectServer("visu1");
47 
48  -# send and/or get Data: client.SendMsg(msgName,vecOfFloats);<br>
49  client.GetData(msgName, newVecOffloats);
50 
51  See the examples also.
52  @author Daniel Grest, Jan. 2004
53  */
54  class BIASNetworkComm_EXPORT CScommClient : public CScommBase {
55  public:
56 
57  /** Set threaded to false for deactivating the receive-thread. Data will be
58  read from TCP-buffer only when GetData methods are called. Threaded
59  receive is activated by default!
60  Beware: if there's no msg in tcp-buffer, GetData will BLOCK until there
61  is any new msg (this need not be the one GetData was called for,
62  for example binary instead of int)
63  if receive-buffer is completly filled, send blocks until msg
64  can be delivered!
65  */
66  CScommClient(bool threaded = true);
68 
69  /** give the client a name, default ist $HOSTNAME
70  */
71  void SetName(std::string clientName) { name_=clientName;}
72 
73  /** for a client: tries to connect to server with hostname serverName.
74  @param timeOut in ms
75  @param serverName hostName of the server as ip or name
76  @return 0 on success, -1 on timeOut, < -1 on other errors
77  */
78  int ConnectServer(std::string serverName,unsigned int port=D_CS_DEFAULT_PORT,
79  unsigned int timeOut=20000);
80 
81  };
82 }
83 
84 #endif
class for sending/receiving data between clients and servers
Definition: CScommClient.hh:54
this class CScomm (ClientServer communciation) handles data comunication via TCP/IP for one server an...
Definition: CScommBase.hh:73
void SetName(std::string clientName)
give the client a name, default ist $HOSTNAME
Definition: CScommClient.hh:71