Board index » delphi » Indy Socket Options

Indy Socket Options

I am trying to set a socket option on a TIdIPMCastClient binding but am having some trouble.  My code is as follows: -

Binding := IdIPMCastClient1.Bindings.Add;
Binding.Port := 9000;
Binding.SetSockOpt(Id_SOL_SOCKET, Id_SO_REUSEADDR, nil, 0);

Unfortunately, this fails when the socket option is set with error 10038 - Socket operation on non-socket.

Basically, I want two instances of the same program on the same computer to listen to the multicast group.

Can anyone please help.

Thanks,

Ian.

 

Re:Indy Socket Options


Quote
On Thu, 14 Nov 2002 05:09:16 +0000, Ian Davies wrote:
> Binding := IdIPMCastClient1.Bindings.Add; Binding.Port := 9000;
> Binding.SetSockOpt(Id_SOL_SOCKET, Id_SO_REUSEADDR, nil, 0);

Shouldn't this look like this:
SetSockOpt(Id_SOL_SOCKET, Id_SO_REUSEADDR, PChar(@Id_SO_True),
SizeOf(Id_SO_True));

(where Id_SO_True is a constant)?
This is taken right from the Indy source code.

johannes

Re:Indy Socket Options


Thank you for your response.  I have made the changes you suggested but I get the same error message.  Do you know if this operation is valid on a Multicast socket binding?

Thanks,

Ian.

Quote
"Johannes Berg" <johan...@sipsolutions.de> wrote:
>On Thu, 14 Nov 2002 05:09:16 +0000, Ian Davies wrote:

>> Binding := IdIPMCastClient1.Bindings.Add; Binding.Port := 9000;
>> Binding.SetSockOpt(Id_SOL_SOCKET, Id_SO_REUSEADDR, nil, 0);

>Shouldn't this look like this:
>SetSockOpt(Id_SOL_SOCKET, Id_SO_REUSEADDR, PChar(@Id_SO_True),
>SizeOf(Id_SO_True));

>(where Id_SO_True is a constant)?
>This is taken right from the Indy source code.

>johannes

Re:Indy Socket Options


Quote
On Thu, 14 Nov 2002 05:50:29 +0000, Ian Davies wrote:

> Thank you for your response.  I have made the changes you suggested but I
> get the same error message.  Do you know if this operation is valid on a
> Multicast socket binding?

No, sorry, I don't.

johannes

Re:Indy Socket Options


MS Help says:

SO_REUSEADDR

"By default, a socket cannot be bound (see bind) to a local address
which is already in use. On occasion, however, it may be necessary to
"re-use" an address in this way. Since every connection is uniquely
identified by the combination of local and remote addresses, there is
no problem with having two sockets bound to the same local address as
long as the remote addresses are different. To inform the Windows
Sockets provider that a bind on a socket should not be disallowed
because the desired address is already in use by another socket, the
application should set the SO_REUSEADDR socket option for the socket
before issuing the bind. Note that the option is interpreted only at
the time of the bind: it is therefore unnecessary (but harmless) to
set the option on a socket which is not to be bound to an existing
address, and setting or resetting the option after the bind has no
effect on this or any other socket."

Note that you can't reuse the address to listen to the same remote
address.

I had to implement something like this and did it by writing a service
that listened to the Multicast group via Indy Multicast client. I then
have various applications connecting to the service as required.

Quote
"Ian Davies" <i...@nospam.com> wrote in message

news:3dd3aa25$1@newsgroups.borland.com...
Quote

> Thank you for your response.  I have made the changes you suggested

but I get the same error message.  Do you know if this operation is
valid on a Multicast socket binding?
Quote

Re:Indy Socket Options


Thanks for the response, Ben.  This makes sense, I suppose, and I now understand your reasoning behind writing a server for your other clients.

If the socket options must be set before the bind occurs, how does this work in Indy?  Do the bindings actually occur when the component is activated?

Thanks,

Ian.

Quote
"Ben Hay" <b...@NoSpamtsl.com.au> wrote:
>MS Help says:

>SO_REUSEADDR

>"By default, a socket cannot be bound (see bind) to a local address
>which is already in use. On occasion, however, it may be necessary to
>"re-use" an address in this way. Since every connection is uniquely
>identified by the combination of local and remote addresses, there is
>no problem with having two sockets bound to the same local address as
>long as the remote addresses are different. To inform the Windows
>Sockets provider that a bind on a socket should not be disallowed
>because the desired address is already in use by another socket, the
>application should set the SO_REUSEADDR socket option for the socket
>before issuing the bind. Note that the option is interpreted only at
>the time of the bind: it is therefore unnecessary (but harmless) to
>set the option on a socket which is not to be bound to an existing
>address, and setting or resetting the option after the bind has no
>effect on this or any other socket."

>Note that you can't reuse the address to listen to the same remote
>address.

>I had to implement something like this and did it by writing a service
>that listened to the Multicast group via Indy Multicast client. I then
>have various applications connecting to the service as required.

>"Ian Davies" <i...@nospam.com> wrote in message
>news:3dd3aa25$1@newsgroups.borland.com...

>> Thank you for your response.  I have made the changes you suggested
>but I get the same error message.  Do you know if this operation is
>valid on a Multicast socket binding?

Other Threads