Commit d7dcf8bd authored by Pavel Vainerman's avatar Pavel Vainerman

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

parent 312ddd32
......@@ -14,7 +14,8 @@ initPause(0),
udp(0),
activated(false),
dlist(100),
maxItem(0)
maxItem(0),
packetnum(1)
{
if( objId == DefaultObjectId )
throw UniSetTypes::SystemError("(UDPExchange): objId=-1?!! Use --udp-name" );
......@@ -224,11 +225,43 @@ void UDPExchange::poll()
void UDPExchange::send()
{
cout << myname << ": send..." << endl;
/*
UniSetUDP::UDPHeader h;
h.nodeID = conf->getLocalNode();
h.procID = getId();
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) )
{
ssize_t ret = udp->send((char*)(&h),sizeof(h));
......@@ -245,7 +278,6 @@ void UDPExchange::send()
{
// while( !udp->isPending(ost::Socket::pendingOutput) )
// msleep(30);
cout << myname << "(send): " << (*it) << endl;
ssize_t ret = udp->send((char*)(&(*it)),sizeof(UniSetUDP::UDPData));
if( ret<(ssize_t)sizeof(UniSetUDP::UDPData) )
......@@ -255,6 +287,7 @@ void UDPExchange::send()
}
}
// }
#endif
}
// -----------------------------------------------------------------------------
void UDPExchange::processingMessage(UniSetTypes::VoidMessage *msg)
......
......@@ -113,6 +113,10 @@ class UDPExchange:
ReceiverList rlist;
ThreadCreator<UDPExchange>* thr;
static const int MaxDataLen = 8192;
char udpbuf[MaxDataLen];
long packetnum;
};
// -----------------------------------------------------------------------------
#endif // UDPExchange_H_
......
......@@ -117,7 +117,7 @@ void UDPNReceiver::recv()
return;
}
#endif
cout << "***** request: " << udp->UDPSocket::getIPV4Peer() << endl;
//cout << "***** request: " << udp->UDPSocket::getIPV4Peer() << endl;
for( int i=0; i<100;i++ )
{
ssize_t ret = udp->UDPReceive::receive(&d,sizeof(d));
......
......@@ -11,6 +11,7 @@ namespace UniSetUDP
{
struct UDPHeader
{
long num;
long nodeID;
long procID;
long dcount;
......
#!/bin/sh
uniset-start.sh -f ./uniset-udpexchange --udp-name UDPExchange --udp-host 192.168.56.255 \
--udp-broadcast 1 --udp-polltime 1000 \
uniset-start.sh -f ./uniset-udpexchange --udp-name UDPExchange --udp-host 192.168.1.255 \
--udp-broadcast 1 --udp-polltime 100 \
--confile test.xml \
--dlog-add-levels info,crit,warn
# --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