UDP and OT
UDP and OT
- Subject: UDP and OT
- From: <email@hidden>
- Date: Wed, 11 Dec 2002 00:09:00 +0000
- Organization: Coderus Ltd
Hi,
I have playing with some of OT calls, so that I can find other machine
running my appl, so thinking of sending out an UDP message to anyone
listening on a specified port, so I thought the below code would work
EndpointRef endPoint;
InetAddress dest_addr;
TUnitData udata;
Initialize();
endPoint = OTOpenEndpointInContext( OTCreateConfiguration(kUDPName), 0,
nil, &err, NULL);
err = OTBind(endPoint, nil, nil);
OTInitInetAddress(&dest_addr, 3200, kOTAnyInetAddress);
udata.addr.len = sizeof(dest_addr);
udata.addr.maxlen = sizeof(dest_addr);
udata.addr.buf = (unsigned char *) &dest_addr;
udata.opt.len = 0;
udata.opt.maxlen = 0;
udata.opt.buf = nil;
// Does it copy the data ???
udata.udata.len = 30;
udata.udata.maxlen = 30;
udata.udata.buf = (UInt8 *) NewPtr (30);
if ( which == 1 )
{
//
// Send the data to anybody listening on Port 3200, UDP port
//
err = OTSndUData(endPoint, &udata );
// wait for replies I guess
}
else
{
//
// listening on Port 3200, UDP port, and see if anyone calls
//
OTSetBlocking(endPoint);
err = OTRcvUData(endPoint, &udata, NULL );
// Send a response back about my self.
}
OTCloseProvider(endPoint);
this code is fairly simplistic at the minute, but I just wanted to do
proof of concept first.
Any ideas, what I'm doing wrong. This code is ran on 2 machines with the
correct directive.
Also why do you need to OTBind, as you usually don't need to do a bind
unless you want specific port ???, usually when listening ???, but I got an
error before I added, when I was trying to do the OTSndUdata, of endpoint in
wrong state (-3155 I think it was)
Thanks in advance,
Mark.
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.