Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/echo/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ int main(int argc, char *argv[])

// Start the client with a protocol name (must be the same than the one used by the server)
// the server host and port and with packet encryption on or off
if (NBN_GameClient_StartEx(ECHO_PROTOCOL_NAME, "127.0.0.1", ECHO_EXAMPLE_PORT, NULL, 0) < 0)
if (NBN_GameClient_StartEx(ECHO_PROTOCOL_NAME, "localhost", ECHO_EXAMPLE_PORT, NULL, 0) < 0)
{
Log(LOG_ERROR, "Failed to start client");

Expand Down
6 changes: 4 additions & 2 deletions nbnet.h
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ void NBN_Channel_UpdateMessageLastSendTime(NBN_Channel *, NBN_Message *, double)

Guarantee that messages will be received in order, does not however guarantee that all message will be received when
packets get lost. This is meant to be used for time critical messages when it does not matter that much if they
end up getting lost. A good example would be game snaphosts when any newly received snapshot is more up to date
end up getting lost. A good example would be game snapshots when any newly received snapshot is more up to date
than the previous one.
*/
typedef struct NBN_UnreliableOrderedChannel
Expand Down Expand Up @@ -4590,13 +4590,15 @@ int NBN_GameClient_StartEx(const char *protocol_name, const char *host, uint16_t
nbn_game_client.is_connected = false;
nbn_game_client.closed_code = -1;

const char *resolved_host = strcmp(host, "localhost") == 0 ? "127.0.0.1" : host;

for (unsigned int i = 0; i < NBN_MAX_DRIVERS; i++)
{
NBN_Driver *driver = &nbn_drivers[i];

if (driver->id < 0) continue;

if (driver->impl.cli_start(Endpoint_BuildProtocolId(protocol_name), host, port) < 0)
if (driver->impl.cli_start(Endpoint_BuildProtocolId(protocol_name), resolved_host, port) < 0)
{
NBN_LogError("Failed to start driver %s", driver->name);
return NBN_ERROR;
Expand Down