The Original CHomP Software
mwlowlev.h
Go to the documentation of this file.
1
3
16
17// Copyright (C) 1997-2020 by Pawel Pilarczyk.
18//
19// This file is part of my research software package. This is free software:
20// you can redistribute it and/or modify it under the terms of the GNU
21// General Public License as published by the Free Software Foundation,
22// either version 3 of the License, or (at your option) any later version.
23//
24// This software is distributed in the hope that it will be useful,
25// but WITHOUT ANY WARRANTY; without even the implied warranty of
26// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27// GNU General Public License for more details.
28//
29// You should have received a copy of the GNU General Public License
30// along with this software; see the file "license.txt". If not,
31// please, see <https://www.gnu.org/licenses/>.
32
33// Started on August 11, 2004. Last revision: November 29, 2007.
34
35
36#ifndef _CHOMP_MULTIWORK_MWLOWLEV_H_
37#define _CHOMP_MULTIWORK_MWLOWLEV_H_
38
39#include <string>
40
41namespace chomp {
42namespace multiwork {
43
44// --------------------------------------------------
45// ---------- network communication flags -----------
46// --------------------------------------------------
47
52{
54 mwNone = 0,
55
57 mwCanRead = 0x01,
58
60 mwCanWrite = 0x02,
61
64
66 mwLost = -5
67
68}; /* enum mwIOconstants */
69
70
71// --------------------------------------------------
72// ------------- network communication --------------
73// --------------------------------------------------
74// The following functions are implemented
75// in a system-dependent way in the "mw_*.cpp" files
76// one of which (or all) must be linked with the program.
77
80int mwSendBytes (int fd, const char *buf, int len);
81
84int mwRecvBytes (int fd, char *buf, int len);
85
88int mwConnect (const char *name, int port);
89
92int mwListen (int port, int queuesize);
93
97int mwAccept (int fd, std::string &computer, int timeout = -1);
98
103int mwSelect (const int *workers, int nworkers, int listensocket,
104 int *ioflags, int timeout);
105
108void mwDisconnect (int fd);
109
110
111} // namespace multiwork
112} // namespace chomp
113
114#endif // _CHOMP_MULTIWORK_MWLOWLEV_H_
115
117
int mwSendBytes(int fd, const char *buf, int len)
Sends the given buffer to the given socket.
mwIOconstants
Input/output flags and error codes used for network communication, mainly for the 'select' function t...
Definition: mwlowlev.h:52
@ mwTimeOut
A connection time out has occurred.
Definition: mwlowlev.h:63
@ mwCanWrite
Writing possible.
Definition: mwlowlev.h:60
@ mwCanRead
Reading possible.
Definition: mwlowlev.h:57
@ mwNone
No flag selected.
Definition: mwlowlev.h:54
@ mwLost
The network connection has been lost.
Definition: mwlowlev.h:66
int mwListen(int port, int queuesize)
Begins listening at the given port.
int mwSelect(const int *workers, int nworkers, int listensocket, int *ioflags, int timeout)
Determines IOflags for each of the workers and additionally the listensocket (the last flag).
int mwAccept(int fd, std::string &computer, int timeout=-1)
Waits for and accepts a connection at the given socket.
void mwDisconnect(int fd)
Disconnects the given socket.
int mwRecvBytes(int fd, char *buf, int len)
Receives the given amount of data from the given socket.
int mwConnect(const char *name, int port)
Connects to the given computer at the given port.
This namespace contains the entire CHomP library interface.
Definition: bitmaps.h:51