EldoS | Feel safer!

Software components for data protection, secure storage and transfer

UDP Broadcast with TElSocket

Also by EldoS: MsgConnect
Cross-platform protocol-independent communication framework for building peer-to-peer and client-server applications and middleware components.
#31430
Posted: 11/18/2014 18:14:24
by Erich Kuba (Standard support level)
Joined: 05/16/2013
Posts: 38

Hi there,

I'm busy converting all my applications to use your socket component so that I can port all my code to Android/iOS etc.

Anyway, I seem to be having a problem with UDP broadcasts not working. If I send the packet to a specified IP Address, then it works fine, but if I send to 255.255.255.255, then the SendTo() method returns -1;

Please advise what I'm doing wrong;

Kind regards

Erich
#31432
Posted: 11/19/2014 01:35:12
by Vsevolod Ievgiienko (EldoS Corp.)

Thank you for contacting us.

Do you have a problem on Android, iOS or both?
#31433
Posted: 11/19/2014 02:08:30
by Erich Kuba (Standard support level)
Joined: 05/16/2013
Posts: 38

Thanks for getting back to me ... I have not yet tested this specific code on Android or iOS ... this specific fault was found in my Windows development environment (which is my first dev environment).
#31434
Posted: 11/19/2014 02:18:27
by Vsevolod Ievgiienko (EldoS Corp.)

Please find next code in SBSocket.pas and its TElSocket.SendTo method:

Code
if addr = LongWord(INADDR_NONE) then
        raise EElSocketError.Create(sInvalidAddress, SB_SOCKET_ERROR_INVALID_ADDRESS);
    end
    else
      addr := {$ifdef SB_WINDOWS}Cardinal(INADDR_NONE);{$else}INADDR_NONE; // CHANFE CONSTANT HERE !!!{$endif}


and change INADDR_NONE to INADDR_BROADCAST. Then check if this helps.
#31459
Posted: 11/19/2014 21:34:25
by Erich Kuba (Standard support level)
Joined: 05/16/2013
Posts: 38

Thanks for getting back to me, but the lines of code that you refer to are excluded by the compiler directive {$ifdef SB_IPv6} on line 4458.

Please advise.
#31465
Posted: 11/20/2014 05:58:24
by Vsevolod Ievgiienko (EldoS Corp.)

The problem is described here: http://msdn.microsoft.com/en-us/libra...s.85).aspx See WSAEACCES error description. You should enable broadcasts using setsockopt function.
#31469
Posted: 11/20/2014 20:31:30
by Erich Kuba (Standard support level)
Joined: 05/16/2013
Posts: 38

Thank you. Once again you've come to the rescue.
Also by EldoS: Solid File System
A virtual file system that offers a feature-rich storage for application documents and data with built-in compression and encryption.

Reply

Statistics

Topic viewed 517 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!