EldoS | Feel safer!

Software components for data protection, secure storage and transfer

UDP Broadcast with TElSocket

Also by EldoS: Rethync
The cross-platform framework that simplifies synchronizing data between mobile and desktop applications and servers and cloud storages
#31430
Posted: 11/18/2014 18:14:24
by Erich Kuba (Standard support level)
Joined: 05/16/2013
Posts: 41

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 (Team)

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: 41

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 (Team)

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: 41

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 (Team)

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: 41

Thank you. Once again you've come to the rescue.
Also by EldoS: CallbackFilter
A component to monitor and control disk activity, track file and directory operations (create, read, write, rename etc.), alter file data, encrypt files, create virtual files.

Reply

Statistics

Topic viewed 637 times

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




|

Back to top

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

Got it!