diff options
Diffstat (limited to 'lib/kernel/test')
-rw-r--r-- | lib/kernel/test/socket_client.erl | 15 | ||||
-rw-r--r-- | lib/kernel/test/socket_server.erl | 10 |
2 files changed, 24 insertions, 1 deletions
diff --git a/lib/kernel/test/socket_client.erl b/lib/kernel/test/socket_client.erl index 094b7eebc5..56424457e0 100644 --- a/lib/kernel/test/socket_client.erl +++ b/lib/kernel/test/socket_client.erl @@ -71,6 +71,10 @@ start(Domain, Type, Proto, Addr, Port) -> SA = #{family => Domain, addr => Addr, port => Port}, + %% The way we use tos only works because we + %% send so few messages (a new value for every + %% message). + put(tos, 1), do_start(Domain, Type, Proto, SA). do_start(Domain, stream = Type, Proto, SA) -> @@ -186,6 +190,7 @@ do_init(Domain, stream = Type, Proto) -> i("try (socket) bind"), case socket:bind(Sock, any) of {ok, _P} -> + ok = socket:setopt(Sock, ip, tos, mincost), Sock; {error, BReason} -> throw({bind, BReason}) @@ -271,7 +276,15 @@ send(#client{socket = Sock, type = dgram, dest = Dest}, Msg) -> %% i("try send to: " %% "~n ~p", [Dest]), %% ok = socket:setopt(Sock, otp, debug, true), - socket:sendto(Sock, Msg, Dest). + TOS = get(tos), + ok = socket:setopt(Sock, ip, tos, TOS), + case socket:sendto(Sock, Msg, Dest) of + ok = OK -> + put(tos, TOS+1), + OK; + {error, _} = ERROR -> + ERROR + end. recv(#client{socket = Sock, type = stream}) -> case socket:recv(Sock) of diff --git a/lib/kernel/test/socket_server.erl b/lib/kernel/test/socket_server.erl index f252be1683..34f354be32 100644 --- a/lib/kernel/test/socket_server.erl +++ b/lib/kernel/test/socket_server.erl @@ -900,8 +900,18 @@ peek_recvfrom(Sock, BufSz) -> end. +send(#handler{socket = Sock, msg = true, type = stream}, Msg, _) -> + MsgHdr = #{iov => [Msg]}, + socket:sendmsg(Sock, MsgHdr); send(#handler{socket = Sock, type = stream}, Msg, _) -> socket:send(Sock, Msg); +send(#handler{socket = Sock, msg = true, type = dgram}, Msg, Dest) -> + MsgHdr = #{addr => Dest, + iov => [Msg]}, + %% ok = socket:setopt(Sock, otp, debug, true), + Res = socket:sendmsg(Sock, MsgHdr), + %% ok = socket:setopt(Sock, otp, debug, false), + Res; send(#handler{socket = Sock, type = dgram}, Msg, Dest) -> socket:sendto(Sock, Msg, Dest). |