x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

FSocket->Bind() resulst in SE_EADDRNOTAVAIL

Hi, im going crazy over here...

I successfully created udp sockets before but now it always results in the socket error 21 "Address is not available" or as ESocketError SE_EADDRNOTAVAIL.... I tried it on different PCs with version 4.1 and 4.2... set the Socket as reusable and not... created everything by hand and tried the UdpSocketBuilder...

it ALWAYS resulted in this error...

I even wrote a little console application in C# to verify that my PC's Socket API works... it does

when i debugged, i saw that my address and port order are reversed so i tried different ip adresses as A.B.C.D and D.C.B.A

Here is my code:

 void AUdpActor::createSocket()
 {
     ISocketSubsystem* theSocketSubsystem;
     theSocketSubsystem = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM);
 
 
     ESocketErrors err;
     TSharedPtr<FSocket, ESPMode::NotThreadSafe> Socket;
     TSharedPtr<FInternetAddr, ESPMode::NotThreadSafe> addr;
     addr = theSocketSubsystem->CreateInternetAddr();
 
     addr->SetPort(21338);
 
     bool bIsValid;
     addr->SetIp(TEXT("192.168.2.222"), bIsValid);
 
     Socket = MakeShareable(theSocketSubsystem->CreateSocket(NAME_DGram, TEXT("testSocket"), true));
     Socket->SetReuseAddr(true);
     Socket->Bind(*addr);
     err = theSocketSubsystem->GetLastErrorCode();
 
 
     // second try with the Socket Builder
     FSocket* Socket = FUdpSocketBuilder(TEXT("SomeSocket")).BoundToAddress(FIPv4Address(192, 168, 2, 222)).BoundToPort(23123).AsReusable().Build();
 }
 

I am glad for every suggestion someone might have...

Product Version: Not Selected
Tags:
more ▼

asked Jun 20 '14 at 11:34 AM in C++ Programming

avatar image

Dave4723
329 10 16 33

avatar image Dave4723 Jun 20 '14 at 01:08 PM

i can however bind sockets to ip 0.0.0.0 or 127.0.0.1 but i just don't understand why i cannot bind to other

avatar image MasterOfDreams Jun 30 '14 at 10:11 PM

Address 0.0.0.0 means "any adapter". In UDP you just create a server and a host. Server can get or send messages from lots of hosts. And address of the host you can get, when recieving message. So, server dont need to know its ip. Only port. And you need to Bind ONLY server.

avatar image Dave4723 Jul 02 '14 at 09:56 AM

Thanks for your answer but i am still a little bit confused... In all the examples on the internet (e.g. msdn article) they are setting the receiving udp socket to the sender's ip. So if i know i'm gonna receive data from aa.bb.cc.dd i would set the ip address for my receiving socket to this address. I know that i can just bind to the port and check the incoming frames for the right ip address and discard the wrong ones. But since every example i read on this topic binds sockets to a specific address i considered it as bad practice

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question