1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Add the option to bind to a specific address

This commit is contained in:
ShadowNinja 2014-02-05 21:24:46 +01:00 committed by sapier
parent 7f743178db
commit 85fe75d1cb
12 changed files with 118 additions and 40 deletions

View file

@ -1506,11 +1506,13 @@ struct TestSocket: public TestBase
void Run()
{
const int port = 30003;
Address address(0,0,0,0, port);
Address address6((IPv6AddressBytes*) NULL, port);
// IPv6 socket test
{
UDPSocket socket6(true);
socket6.Bind(port);
socket6.Bind(address6);
const char sendbuffer[] = "hello world!";
IPv6AddressBytes bytes;
@ -1536,7 +1538,7 @@ struct TestSocket: public TestBase
// IPv4 socket test
{
UDPSocket socket(false);
socket.Bind(port);
socket.Bind(address);
const char sendbuffer[] = "hello world!";
socket.Send(Address(127,0,0,1,port), sendbuffer, sizeof(sendbuffer));
@ -1656,7 +1658,8 @@ struct TestConnection: public TestBase
infostream<<"** Creating server Connection"<<std::endl;
con::Connection server(proto_id, 512, 5.0, false, &hand_server);
server.Serve(30001);
Address address(0,0,0,0, 30001);
server.Serve(address);
infostream<<"** Creating client Connection"<<std::endl;
con::Connection client(proto_id, 512, 5.0, false, &hand_client);