How to set up TIdUDPServer binding Programmatically

Roger Alcindor
Roger Alcindor used Ask the Experts™
on
I am trying to set up a binding on an Indy 10 TIdUDPServer component with Embarcadero XE 10.1 Berlin  C++ builder

I As soon as the Bind() call is made, I get an error message as follows:

"Exception class EIdNotAsocket with message 'socket Error #10038' Socket Operation on non-socket."

How can I set up the binding ?

the following is my code:

	TIdSocketHandle *h;
	udpserver = new TIdUDPServer(NULL);
	udpserver->OnUDPRead = IdUDPServer1UDPRead;
	h = udpserver->Bindings->Add();
	h->Port = 791;
	h->IP   = "127.0.0.1";
	try
	{
		h->Bind();
	}
	catch(...)
	{
	};

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Replace h->bind() to udpserver.active = true to start binding socket with udpserver. When you use Bindings.Add() you are aliocated a socket and bind this when udpserver.active is true.

Author

Commented:
Thanks for the comment.
I had forgotten, it was some time since I needed to program the bindings.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial