Indy 10: multicasting in Windows and MAC with Delphi XE2

Hi everyone,
I am trying the new version of Delphi, XE2. 
I want to make a mDNS client / server, so I have placed the components TIdIPMCastClient and TIdIPMCastServer, and configured them.

Under Windows, I have been able to send packets using the TIdIPMCastServer, although they are not with the source port 5353 (the one for mDNS), because I get always the error "address already in use". How can I workaround this problem, so I can send multicast datagrams with source port 5353?
But under MAC, I have alway the error "Socket error #22, invalid argument". I have tried two ways, and I always arrived there: the first when I set the option to reuse the socket via "  IdIPMCastServer1.Binding.SetSockOpt(Id_SOL_SOCKET, Id_SO_REUSEADDR, Id_SO_True);"
The second one, when I try to send the packet directly (without that option), by using "IdIPMCastServer1.Binding.SendTo('224.0.0.251',5353,LBuff);".

Thanks in advance,
Ruben
0
Utf
9/20/2011 11:35:21 AM
embarcadero.delphi.tools 5366 articles. 3 followers. Follow

5 Replies
4260 Views

Similar Articles

[PageSpeed] 21

"Rubén Valls Blasco" <=?Utf-8?Q?Rub=C3=A9n_Valls_Blasco?=> wrote in message 
news:402911@forums.embarcadero.com...

> Under Windows, I have been able to send packets using
> the TIdIPMCastServer, although they are not with the
> source port 5353 (the one for mDNS), because I get
> always the error "address already in use".

You have another socket on your machine that is already using that same 
IP/Port pair.  You can use netstat and SysInternals tools to figure out what 
app is using that IP/Port.

> I set the option to reuse the socket via " 
> IdIPMCastServer1.Binding.SetSockOpt(Id_SOL_SOCKET, Id_SO_REUSEADDR, 
> Id_SO_True);"

TIdIPMCastServer has a ReuseSocket property that you can set to rsTrue 
instead.

> The second one, when I try to send the packet directly
> (without that option), by using 
> "IdIPMCastServer1.Binding.SendTo('224.0.0.251',5353,LBuff);".

Accessing the Binding property calls Bind() the first time the socket is 
allocated, which will then raise the exception.

--
Remy Lebeau (TeamB)
0
Remy
9/20/2011 7:03:51 PM
Hi, thanks for your answer.

Yes, there is an application using that IP and port. In fact, it is the mDNS service in both OS (Bonjour under Windows).

Under Windows, I am fine with the results. I can listen for that IP and port, and I can send datagrams to them.

Now the problem is under MAC OS X, where I can't do anything because of the raising of the exception "Address Already in use", when I create the TIdIPMCastClient component, despite setting the ReuseSocket property to rsTrue. The TidIPMCastServer hasn't got that property.

I initialize both components this way:

{code}
  Showmessage(IdIPMCastClient.Version);  //The version is 10.5.8.0

  IdIPMCastClient.MulticastGroup := '224.0.0.251';
  IdIPMCastClient.DefaultPort := 5353;
  IdIPMCastClient.OnIPMCastRead := IdIPMCastClient1IPMCastRead;
  IdIPMCastClient.ReuseSocket := rsTrue;
  IdIPMCastClient.Active := true;  //Under MAC, it raises the exception here

  IdIPMCastServer.MulticastGroup := '224.0.0.251';
  IdIPMCastServer.Port := 5353;
  IdIPMCastServer.TimeToLive := 1;
  IdIPMCastServer.Loopback := False;
  IdIPMCastServer.Active := true;
{code}

Any help is appreciated.
Thanks in advance,
Rubén
0
Utf
9/21/2011 6:58:40 AM
"Rubén Valls Blasco" <=?Utf-8?Q?Rub=C3=A9n_Valls_Blasco?=> wrote in message 
news:403313@forums.embarcadero.com...

> Now the problem is under MAC OS X, where I can't do anything because
> of the raising of the exception "Address Already in use", when I create 
> the
> TIdIPMCastClient component, despite setting the ReuseSocket property
> to rsTrue. The TidIPMCastServer hasn't got that property.

The ReuseSocket property was added to several components, including 
TIdIPMCastServer, 2 months ago.  Make sure you are using an up-to-date 
version of Indy.

>  IdIPMCastClient.Active := true;  //Under MAC, it raises the exception 
> here

Can you please provide the call stack when the exception occurs?

-- 
Remy Lebeau (TeamB)
0
Remy
9/21/2011 5:30:21 PM
"Rubén Valls Blasco" <=?Utf-8?Q?Rub=C3=A9n_Valls_Blasco?=> wrote in message 
news:402911@forums.embarcadero.com...
> Under Windows, I have been able to send packets using the
> TIdIPMCastServer, although they are not with the source
> port 5353 (the one for mDNS), because I get always the error
> "address already in use". How can I workaround this problem,
> so I can send multicast datagrams with source port 5353?
> But under MAC, I have alway the error "Socket error #22,
> invalid argument". I have tried two ways, and I always arrived
> there: the first when I set the option to reuse the socket via
> "  IdIPMCastServer1.Binding.SetSockOpt(Id_SOL_SOCKET, Id_SO_REUSEADDR, 
> Id_SO_True);"
> The second one, when I try to send the packet directly
> (without that option), by using
> "IdIPMCastServer1.Binding.SendTo('224.0.0.251',5353,LBuff);".

You are trying to bind to the common Multicast port which is used by the 
Bonjour Daemon on the Mac, which is UDP 5353, too.

Lookup 5353 in: http://support.apple.com/kb/ts1629

Bonjour is running exclusively on 5353, not providing something like 
SO_REUSEADDR/SO_REUSEPORT.

The same would apply if you installed iTunes on Windows which comes with 
Bonjour too - due to the widespread usage of iTunes that might have been the 
reason for the error on Windows too.

You can verify, by running "netstat -abn" which prints all used tcp/udp 
ports on windows, with the program name...

--
Remy Lebeau (TeamB)
0
Remy
10/14/2011 12:44:20 AM
> {quote:title=Remy Lebeau (TeamB) wrote:}{quote}
> You are trying to bind to the common Multicast port which is used by the 
> Bonjour Daemon on the Mac, which is UDP 5353, too.
> 
> Lookup 5353 in: http://support.apple.com/kb/ts1629
> 
> Bonjour is running exclusively on 5353, not providing something like 
> SO_REUSEADDR/SO_REUSEPORT.
> 
> The same would apply if you installed iTunes on Windows which comes with 
> Bonjour too - due to the widespread usage of iTunes that might have been the 
> reason for the error on Windows too.
> 
> You can verify, by running "netstat -abn" which prints all used tcp/udp 
> ports on windows, with the program name...
> 
> --
> Remy Lebeau (TeamB)

Thank you for the answer. I haven't seen your reply, that is the delay.
Yes, I figured it out, that the Bonjour service was using it. What I didn't know is that you can bind to port in an exclusive mode.

I have work-arounded the problem by, instead of doing myself the protocol, calling directly to the service's API under MAC. Under Windows, I haven't got problems once I updated to the lattest version and used the Reuse property.

Thank you very much,
Rubén
0
Utf
10/27/2011 7:36:17 AM
Reply:

Similar Artilces:

Converting Delphi 2007 Indy 10.2.3 to Delphi 2009 Indy 10.5.5 [Edit]
Hello, I am currently attempting to port over a Delphi 2007 project that uses Indy 10.2.3 (very successfully) to Delphi 2009 and Indy 10.5.5 (I just got the latest development build this morning). I think I am running into an encoding issue, but am not sure. Specifically, IDHTTP with SSL calls an old CGI and the CGI returns a .zip file and I then save it to the disk. In 2007 and before this worked perfectly. In 2009, it is not. Here is the examples of the 2 different results (though cut way short in the post) I am getting back: 2007: 'PK'#3#4#$14#0#0#0#8#0'rLQ9žrPb€'#0...

migrating from Delphi 6 With Indy 10 to XE7 with Indy 10
I updated the original Indy in D6 to version 10 several years ago. Now I want to migrate my application from D6 to XE7 and would like some feedback on the best route to take. I usually send data using readln and writeln statements. The data is typically XML format. Since migrating to XE7 will include potential unicode data what is the best approach to take when reading and writing data? Will writeln and readln work in these cases or should I be using a different strategy to send unicode data between the tidtcpclient and tidtcpserver applications? al wrote: > I usually send data ...

Indy 10 Delphi XE2 confusion
I have just taken the plunge and updated from Delphi 5 to XE2. In D5 I have been happily using the ClientSocket and ServerSocket components to do some fairly basic TCP comms. I am now trying to understand how to do it using Indy 10. Unfortunately there seems to be very little in the way of examples and doco that is written for non gurus. Is there a huge demo folder somewhere that I have missed seeing? If I understand correctly there also seems to have been a change sometime during Indy 10 from Threads to Contexts. Most of the examples I have been able to find will not compile under XE2, even...

Indy 10 Delphi XE2 confusion
This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --JivePart=_663cb.zeB8CwDOH5aMJzMl Content-Type: text/plain; charset="Utf-8" Updated "Chat 2.0" demo for Indy 10 in XE2. -- Remy Lebeau (TeamB) --JivePart=_663cb.zeB8CwDOH5aMJzMl Content-Type: application/x-zip-compressed; name="Chat.zip" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="Chat.zip" UEsDBBQAAAAAAAyxjD8AAAAAAAAAAAAAAAAQAAAAQ2hhdCAyLjAvQ2xpZW50L1BLAwQUAAAA...

Delphi 7 to Delphi XE2
Hi, Still using that old workhorse, Delphi7, but am going to the conference in London hosted by Embarcadero on Delphi XE2. Although I would like to "move with the times" and am keen to get the UNICODE and 64-bit support offered by the latest IDEs, I confess to being more than a little scared about all the UNICODE/String/AnsiString and 32/64 bit issues I'm probably going to fall over. Anyone recently upgraded from Delphi7 to one of the latest Delphi IDEs? Thanks, Alain On 03/02/2012 08:55, Alain Dekker wrote: > Still using that old workhorse, Delphi7, but...

Delphi XE2 - Indy 10
Dear folks As result of security issues one of the email services in NZ has changed the settings of their email server. It used to be port 25 and outgoing mail was SMTP.xtra.co.nz. The port is now 465 and outgoing mail is now send.xtra.co.nz. The client configuration requires authentication and a secure connection (SSL). The result is that my code to connect for everyone using that provider is now "busted". I have changed the port and outgoing host accordingly. And have set the IOHandler of idSMTP as IdSSLIOHandlerSocketOpenSSL1. With the Authtype as satSASL. I have als...

Delphi 6 BDE/Indy 10 app crashes in Windows 2008?
I've got a user that reports my Delphi 6 BDE/Indy 10 app that crashes immediately after it is launched when being run on Windows 2008. I'm very puzzled as to why it happened as i had ported the application to work on Vista SP1 a few months ago (by creating the manifest) and thought that Vista and Windows 2008 are similar. As i do not have Windows 2008, I'm still trying to find more info from my user (from another country). Has anyone experience problems with Windows 2008? Thanks. :) <joshua lim> wrote in message news:94464@forums.codegear.com... > I've got ...

Delphi XE2, Indy 10
Dear folks The following code is supposed to send a text string to a client that is listening on a set port and ip address. The connection works fine. The problem is that nothing seems to be sent. {code} function TFCSelectForm.SendNitroMessage(NitroRequest: String): String; var sStrm: TMemoryStream; begin try sStrm := TMemoryStream.Create; try sStrm.WriteBuffer(Pointer(NitroRequest)^,Length(NitroRequest)); // sStrm shows as () in the debugger IdTCPClient1.IOHandler.Write(sStrm, 0, False); sStrm.Position := 0; finally ...

delphi 7 Indy 9 and Indy 10
Hi, I can upgrade to indy 10 in delphi 7. But I have discover that indy 9 and Indy 10 have some different properties, so i had to change my old programs that were made in indy 9 to upgrade it to new version, but it is a long work. So I want to know if it is possible to install in the same delphi 7 both versions indy 10 and indy 9. I have tried to do it but i received a error message: Cannot load package 'IndySystem70'. It contains unit 'IdWinSock2', which is also contained in package 'Indy70'. Some can give me ideas or a link to read how to install both versi...

Windows 10 and Delphi
It would be nice if MS would support Object Pascal http://www.nytimes.com/2015/01/19/technology/microsoft-looks-to-windows-10-for-a-jolt-in-the-mobile-realm.html ...

Windows 10 and Delphi
It would be nice if MS would support Object Pascal http://www.nytimes.com/2015/01/19/technology/microsoft-looks-to-windows-10-for-a-jolt-in-the-mobile-realm.html ...

Windows 10 and Delphi
So, this: https://www.youtube.com/watch?v=NfveyXCsiA8 WinRT may not be called WinRT but "Windows Store Apps" are not going away. Microsoft has been pushing and continues to push their Universal Apps as the first-class way to build software for Windows going forward, and it is now obvious that they are not limited to tablet-ey devices and will be front-and-center on the desktop (in windows, yay). Windows Phone may never amount to much from a market share standpoint but "Windows Store" already does. When it comes to consumer-level stuff, it's reasonable to th...

Indy E-Mail Problem (Indy 10, Delphi 2007)
Hello, we use Indy 10 with Delphi 2007 to get E-Mail using IMAP. We recieved an E-Mail which is not handled correctly. The E-Mail looks like this {code} Return-Path: <test@mail.com>; From: "Test Tester" <test@mail.com>; To: <test@mail.com>; Subject: Order Date: Wed, 7 Mar 2012 16:50:40 +0100 Message-ID: <15D526BEB8091D43859549D9E16E370FBA3123> MIME-Version: 1.0 Content-Type: text/html; charset=US-ASCII Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQFk6K6fcF3...

Delphi 64bit versus Delphi Mac/Linux
interesting comments... http://www.deltics.co.nz/blog/?p=452 "Ralf Stocker" <nospam@nospam.com> wrote in message news:127800@forums.codegear.com... > interesting comments... > http://www.deltics.co.nz/blog/?p=452 A very small fraction of Delphi users actually need the memory access of 64 bit, and 32 bit apps will work the same on x64 anyway. A small fraction of Delphi users actually need cross-platform support. I'm not sure if having either first will 'save' Delphi from the 'traditional' tools for each platform (VS, Cocoa, Eclipse, et...

Web resources about - Indy 10: multicasting in Windows and MAC with Delphi XE2 - embarcadero.delphi.tools

PS4 to use Gaikai for instant demos, Ustream multicasting, social gameplay
David Perry, CEO and founder of Gaikai, took the stage at today's PlayStation 4 announcement to reveal new details on the next generation of ...

PS4 to use Gaikai for instant demos, UStream multicasting, social gameplay
Michael McWhertor / Polygon : PS4 to use Gaikai for instant demos, UStream multicasting, social gameplay — David Perry, CEO and founder of Gaikai, ...

iiNet multicasting IPTV over the NBN
iiNet has become the first ISP to deliver IPTV over the NBN using multicasting technology as part of a trial in Sydney.

NPR's Tomorrow Radio Initiative Brings Multicasting to Digital Radio
... on Public Radio Stations LAS VEGAS, NV Leading the U.S. radio industry in technical innovation and programming, NPR has ensured that multicasting ...

App Store - Documents To Go® - Office Suite
Read reviews, get customer ratings, see screenshots, and learn more about Documents To Go® - Office Suite on the App Store. Download Documents ...

Broadcasting - Wikipedia, the free encyclopedia
This article includes a list of references , related reading or external links , but its sources remain unclear because it lacks inline citations ...

ASCAP - ASCAP Radio Music Licensing
ASCAP Radio Music license authorizes performances of copyrighted musical works

02.06.12 // The Future of Networking
Major technology platforms tend to last about 25 to 30 years. This gives them time to gather sufficient developer momentum, enable a set of transformational ...

High Level Logic (HLL) Project
I've decided to release a 2007 video of the robot demonstration (which will be available for download with the new version sometime relatively ...

What's New At Bridge Ratings
For release August 8, 2007 HD Radio vs. Internet Radio - Which is Radio's Future? Here at Bridge Ratings, we are often asked about HD radio. ...

Resources last updated: 2/8/2016 9:30:57 PM