Commit d7dcf8bd authored by Pavel Vainerman's avatar Pavel Vainerman

попытка встроить в udp номер пакета

parent 312ddd32
...@@ -14,7 +14,8 @@ initPause(0), ...@@ -14,7 +14,8 @@ initPause(0),
udp(0), udp(0),
activated(false), activated(false),
dlist(100), dlist(100),
maxItem(0) maxItem(0),
packetnum(1)
{ {
if( objId == DefaultObjectId ) if( objId == DefaultObjectId )
throw UniSetTypes::SystemError("(UDPExchange): objId=-1?!! Use --udp-name" ); throw UniSetTypes::SystemError("(UDPExchange): objId=-1?!! Use --udp-name" );
...@@ -224,11 +225,43 @@ void UDPExchange::poll() ...@@ -224,11 +225,43 @@ void UDPExchange::poll()
void UDPExchange::send() void UDPExchange::send()
{ {
cout << myname << ": send..." << endl; cout << myname << ": send..." << endl;
/*
UniSetUDP::UDPHeader h; UniSetUDP::UDPHeader h;
h.nodeID = conf->getLocalNode(); h.nodeID = conf->getLocalNode();
h.procID = getId(); h.procID = getId();
h.dcount = mypack.size(); h.dcount = mypack.size();
h.num = packetnum++;
int ind = 0;
memcpy(udpbuf,(char*)(&h),sizeof(h));
ind += sizeof(h);
UniSetUDP::UDPMessage::UDPDataList::iterator it = mypack.dlist.begin();
for( ; it!=mypack.dlist.end(); ++it )
{
memcpy( &(udpbuf[ind]),&(*it),sizeof(UniSetUDP::UDPData));
ind +=sizeof(UniSetUDP::UDPData);
if( ind >= MaxDataLen )
{
cerr << myname << "(send data): data len > " << MaxDataLen << "!!!!" << endl;
return;
}
}
if( udp->isPending(ost::Socket::pendingOutput) )
{
ssize_t ret = udp->send(udpbuf,ind);
if( ret<(ssize_t)ind )
{
cerr << myname << "(send data header): ret=" << ret << " byte count=" << ind << endl;
return;
}
cout << "send OK. byte count=" << ret << endl;
}
#if 0
/*
if( udp->isPending(ost::Socket::pendingOutput) ) if( udp->isPending(ost::Socket::pendingOutput) )
{ {
ssize_t ret = udp->send((char*)(&h),sizeof(h)); ssize_t ret = udp->send((char*)(&h),sizeof(h));
...@@ -245,7 +278,6 @@ void UDPExchange::send() ...@@ -245,7 +278,6 @@ void UDPExchange::send()
{ {
// while( !udp->isPending(ost::Socket::pendingOutput) ) // while( !udp->isPending(ost::Socket::pendingOutput) )
// msleep(30); // msleep(30);
cout << myname << "(send): " << (*it) << endl; cout << myname << "(send): " << (*it) << endl;
ssize_t ret = udp->send((char*)(&(*it)),sizeof(UniSetUDP::UDPData)); ssize_t ret = udp->send((char*)(&(*it)),sizeof(UniSetUDP::UDPData));
if( ret<(ssize_t)sizeof(UniSetUDP::UDPData) ) if( ret<(ssize_t)sizeof(UniSetUDP::UDPData) )
...@@ -255,6 +287,7 @@ void UDPExchange::send() ...@@ -255,6 +287,7 @@ void UDPExchange::send()
} }
} }
// } // }
#endif
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UDPExchange::processingMessage(UniSetTypes::VoidMessage *msg) void UDPExchange::processingMessage(UniSetTypes::VoidMessage *msg)
......
...@@ -113,6 +113,10 @@ class UDPExchange: ...@@ -113,6 +113,10 @@ class UDPExchange:
ReceiverList rlist; ReceiverList rlist;
ThreadCreator<UDPExchange>* thr; ThreadCreator<UDPExchange>* thr;
static const int MaxDataLen = 8192;
char udpbuf[MaxDataLen];
long packetnum;
}; };
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#endif // UDPExchange_H_ #endif // UDPExchange_H_
......
...@@ -117,7 +117,7 @@ void UDPNReceiver::recv() ...@@ -117,7 +117,7 @@ void UDPNReceiver::recv()
return; return;
} }
#endif #endif
cout << "***** request: " << udp->UDPSocket::getIPV4Peer() << endl; //cout << "***** request: " << udp->UDPSocket::getIPV4Peer() << endl;
for( int i=0; i<100;i++ ) for( int i=0; i<100;i++ )
{ {
ssize_t ret = udp->UDPReceive::receive(&d,sizeof(d)); ssize_t ret = udp->UDPReceive::receive(&d,sizeof(d));
......
...@@ -11,6 +11,7 @@ namespace UniSetUDP ...@@ -11,6 +11,7 @@ namespace UniSetUDP
{ {
struct UDPHeader struct UDPHeader
{ {
long num;
long nodeID; long nodeID;
long procID; long procID;
long dcount; long dcount;
......
#!/bin/sh #!/bin/sh
uniset-start.sh -f ./uniset-udpexchange --udp-name UDPExchange --udp-host 192.168.56.255 \ uniset-start.sh -f ./uniset-udpexchange --udp-name UDPExchange --udp-host 192.168.1.255 \
--udp-broadcast 1 --udp-polltime 1000 \ --udp-broadcast 1 --udp-polltime 100 \
--confile test.xml \ --confile test.xml \
--dlog-add-levels info,crit,warn --dlog-add-levels info,crit,warn
# --udp-filter-field udp --udp-filter-value 1 \ # --udp-filter-field udp --udp-filter-value 1 \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment