20 #ifndef __UT_NetMessage__
21 #define __UT_NetMessage__
104 bool tryConnection(
bool *failed=0);
113 void addToFDSet(fd_set *set,
int &maxfd)
const;
119 const char *
data()
const {
return myData; }
120 char *
data() {
return myData; }
124 void resetLength(TransmitState state,
exint newlen);
150 void setWriteSocket(
const char *addr,
int port);
156 { setWriteDataWithHeader(0, data, len); }
158 { setWriteData(data, strlen(data)); }
159 void setWriteDataWithHeader(
exint headersize,
const char *
data,
exint len);
161 { setWriteDataWithHeader(headersize, data, strlen(data)); }
166 { setWriteDataWithHeader(bufsize, 0, 0); }
170 void growWriteData(
exint newlen);
172 static int64 totalBytesSent();
173 static int64 totalBytesReceived();
174 static void clearByteCounters();
187 static void addToTotalNetworkTime(
fpreal64 netnewtime);
194 bool compress(
exint header);
199 bool decompress(
exint header);
204 static int64 ourTotalBytesSent;
205 static int64 ourTotalBytesReceived;
206 static fpreal64 ourTotalNetworkTime;
218 exint mySwapCapacity;
220 TransmitState myState;
228 bool myProcessing64BitLength;
267 myCompleteList.clear();
296 bool pumpData(
int timeoutms);
406 void sendData(
int destpeer, const
char *
data,
exint len);
421 bool pumpData(
int timeoutms);
430 int expectedmessages,
int timeoutms = 100);
437 int expectedmessages,
int timeoutms = 100);
439 bool finishAsyncReceiveDataLoop();
458 template <
class CallbackType>
460 int expectedmessages,
461 CallbackType callback,
466 int goal = complist.entries() + expectedmessages;
469 AutoNetworkTimer timer(
this);
476 if (!pumpData(timeoutms))
490 complist.append(msg);
494 if (!done && gotPeerList() && (complist.entries() >= goal))
528 void sendTrackerMessage(
const char *msg);
530 void startNetworkTimer();
531 void stopNetworkTimer();
558 friend class AutoNetworkTimer;
583 bool openPipes(
int timeoutms = 100);
586 bool closePipes(
int timeoutms = 100);
597 bool transferData(
int timeoutms = 100);
604 bool pumpData(
int timeoutms);
606 void startNetworkTimer();
607 void stopNetworkTimer();
622 friend class AutoNetworkTimer;
649 void waitValue(
int val);
654 int incrementValue(
int defaultval);
658 void sendTrackerMessage(
const char *msg,
int value);
662 void blockUntilComplete();
666 bool pumpData(
int timeoutms);
void reset()
Resets, but does not free any messages it has.
GLenum GLuint GLsizei bufsize
UT_NetSocket * getSocket() const
The socket we are attached to.
UT_ValArray< UT_NetMessage * > myWorkList
void setWriteData(const char *data, exint len)
*get result *(waiting if necessary)*A common idiom is to fire a bunch of sub tasks at the and then *wait for them to all complete We provide a helper class
void setWriteData(const char *data)
exint compressionThreshold() const
void setCompressionThreshold(exint threshold_bytes)
UT_StringHolder myJobName
**And then you can **find out if it s done
void setWriteDataLength(exint bufsize)
UT_ValArray< UT_NetMessage * > myErrorList
UT_ValArray< UT_NetMessage * > myCompleteList
UT_ValArray< UT_NetMessage * > myAnnounce
__hostdev__ void setValue(uint32_t offset, bool v)
UT_ValArray< UT_NetMessage * > myWritePipes
UT_ValArray< UT_NetMessage * > myCompleted
UT_ValArray< UT_NetMessage * > & completed()
UT_ValArray< UT_NetMessage * > myWaitingForPeers
int8 extractInt8(exint offset)
exint myCompressionThreshold
Number of bytes to start compressing at.
int opInterrupt(int percent=-1)
UT_ValArray< UT_NetMessage * > & completed()
Blind write of a pipe for our size.
AutoNetworkTimer(UT_NetMessagePipe *pipe)
void deleteSentMessages(bool shoulddelete)
UT_ValArray< UT_NetMessage * > myReadPipes
void setCompressionThreshold(exint threshold_bytes)
const char * data() const
void setState(TransmitState state)
UT_Array< ut_NetPeerData > myPeerList
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
Connection closed after ack sent.
int getSocketFD() const
File descriptor of socket.
UT_ValArray< UT_NetMessage * > & errored()
exint compressionThreshold() const
UT_StringHolder myAddress
bool gotPeerList() const
Returns if we have received a peer list from the tracker.
UT_NetMessage * writePipe(int peer)
void receiveAnnounce(bool receiveannounce)
UT_API UT_Interrupt * UTgetInterrupt()
Obtain global UT_Interrupt singleton.
TransmitState state() const
Blind read of a pipe for our size.
**But if you need a or simply need to know when the task has * completed
UT_StringHolder myJobName
UT_ValArray< UT_NetSocket * > myServerList
UT_StringHolder myJobName
UT_StringHolder myTrackerAddr
UT_StringHolder myTrackerAddress
exint myCompressionThreshold
Number of bytes to start compressing at.
void setWriteDataWithHeader(exint headersize, const char *data)
AutoNetworkTimer(UT_NetExchange *xchg)
UT_UniquePtr< UT_NetSocket > UT_NetSocketPtr
int pendingMessages() const
The number of messages still pending.
UT_StopWatch * myTimer
We track our elapsed time for printing status.
UT_StringHolder myTrackerAddr