Skip to content

Commit

Permalink
[docs] Replaced CreateAddrInet with CreateAddr (#1408)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsharabayko authored Jul 23, 2020
1 parent 2a7fa31 commit cb4b067
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion apps/srt-live-transmit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
#include <list>


#include "apputil.hpp" // CreateAddrInet
#include "apputil.hpp" // CreateAddr
#include "uriparser.hpp" // UriParser
#include "socketoptions.hpp"
#include "logsupport.hpp"
Expand Down
2 changes: 1 addition & 1 deletion apps/srt-tunnel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <mutex>
#include <condition_variable>

#include "apputil.hpp" // CreateAddrInet
#include "apputil.hpp" // CreateAddr
#include "uriparser.hpp" // UriParser
#include "socketoptions.hpp"
#include "logsupport.hpp"
Expand Down
26 changes: 13 additions & 13 deletions docs/bonding-intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ SRTSOCKET sock = srt_create_socket();
The listener needs to bind it first (note: simplified code):

```
sockaddr_in sa = CreateAddrInet("0.0.0.0:5000");
srt_bind(sock, &sa, sizeof sa);
sockaddr_any sa = CreateAddr("0.0.0.0", 5000);
srt_bind(sock, sa.get(), sa.len);
srt_listen(sock, 5);
sockaddr_in target;
SRTSOCKET connsock = srt_accept(sock, &target, sizeof target);
Expand All @@ -73,8 +73,8 @@ the target:

```
SRTSOCKET connsock = srt_create_socket();
sockaddr_in sa = CreateAddrInet("target.address:5000");
srt_connect(connsock, &sa, sizeof sa);
sockaddr_any sa = CreateAddr("target.address", 5000);
srt_connect(connsock, sa.get(), sa.len);
```

After the connection is established, you use the send/recv functions to
Expand Down Expand Up @@ -133,8 +133,8 @@ To handle group connections, you need to set `SRTO_GROUPCONNECT` option:
int gcon = 1;
srt_setsockflag(sock, SRTO_GROUPCONNECT, &gcon, sizeof gcon);
sockaddr_in sa = CreateAddrInet("0.0.0.0:5000");
srt_bind(sock, &sa, sizeof sa);
sockaddr_any sa = CreateAddr("0.0.0.0", 5000);
srt_bind(sock, sa.get(), sa.len);
srt_listen(sock, 5);
sockaddr_in target;
SRTSOCKET conngrp = srt_accept(sock, &target, sizeof target);
Expand All @@ -155,15 +155,15 @@ SRTSOCKET conngrp = srt_create_group(SRT_GTYPE_BROADCAST);
This will need to make the first connection this way:

```
sockaddr_in sa = CreateAddrInet("target.address.link1:5000");
srt_connect(conngrp, &sa, sizeof sa);
sockaddr_any sa = CreateAddr("target.address.link1", 5000);
srt_connect(conngrp, sa.get(), sizeof sa);
```

Then further connections can be done by calling `srt_connect` again:

```
sockaddr_in sa2 = CreateAddrInet("target.address.link2:5000");
srt_connect(conngrp, &sa2, sizeof sa2);
sockaddr_any sa2 = CreateAddr("target.address.link2", 5000);
srt_connect(conngrp, sa.get(), sa2.len);
```

IMPORTANT: This method can be easily used in non-blocking mode, as
Expand All @@ -176,9 +176,9 @@ So for blocking mode we use a different solution. Let's say, you have
3 addresses:

```
sockaddr_in sa1 = CreateAddrInet("target.address.link1:5000");
sockaddr_in sa2 = CreateAddrInet("target.address.link2:5000");
sockaddr_in sa3 = CreateAddrInet("target.address.link3:5000");
sockaddr_any sa1 = CreateAddr("target.address.link1", 5000);
sockaddr_any sa2 = CreateAddr("target.address.link2", 5000);
sockaddr_any sa3 = CreateAddr("target.address.link3", 5000);
```

You have to prepare the array for them and then use one group-connect function:
Expand Down
2 changes: 1 addition & 1 deletion testing/srt-test-mpbond.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#define REQUIRE_CXX11 1

#include "apputil.hpp" // CreateAddrInet
#include "apputil.hpp" // CreateAddr
#include "uriparser.hpp" // UriParser
#include "socketoptions.hpp"
#include "logsupport.hpp"
Expand Down
2 changes: 1 addition & 1 deletion testing/srt-test-multiplex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#define REQUIRE_CXX11 1

#include "apputil.hpp" // CreateAddrInet
#include "apputil.hpp" // CreateAddr
#include "uriparser.hpp" // UriParser
#include "socketoptions.hpp"
#include "logsupport.hpp"
Expand Down

0 comments on commit cb4b067

Please sign in to comment.