Author Topic: [done] Please handle "Address already in use" socket error more gracefully  (Read 1255 times)

tomreyn

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 2,764
    • View Profile
    • MegaGlest - the free and open source cross platform 3D real-time strategy game
I'm just hosting a headless server on this system for Internet players since there are currently few servers available.
Nevertheless, I would like to be able to start another custom game at the same time, to test a few things. Ideally I could do so without having to change the game configuration.

However, if I start MegaGlest a second time and turn to the custom game menu, MegaGlest crashes immediately without any warning on the GUI with this:
Code: [Select]
megaglest v3.7.0
Compiled using: GNUC: 40702 [64bit] on: Nov 14 2012 21:22:16 platform: Linux-X64 endianness: little
SVN: [Rev: 3911] - using STREFLOP [SSE] - [no-denormals]
[2012-11-14 21:43:07] *ERROR* In [menu_state_custom_game.cpp::MenuStateCustomGame 139]
Network init error:
Error binding socket sock = 16, address [127.0.0.1] port = 61355 err = -1, error = (Error: 98 - [Address already in use])

Stack Trace:
./megaglest:Shared::Platform::megaglest_runtime_error::megaglest_runtime_error(std::string const&, bool)address [0x9b5502] line: 237
./megaglest:Shared::Platform::ServerSocket::bind(int)address [0x9d1ded] line: 2220
./megaglest:Shared::Platform::ServerSocket::listen(int)address [0x9d2007] line: 2247
./megaglest:Glest::Game::ServerInterface::ServerInterface(bool)address [0x7f1865] line: 88
./megaglest:Glest::Game::NetworkManager::init(Glest::Game::NetworkRole, bool)address [0x7d28d9] line: 53
./megaglest:Glest::Game::MenuStateCustomGame::MenuStateCustomGame(Glest::Game::Program*, Glest::Game::MainMenu*, bool, Glest::Game::ParentMenuState, bool, Glest::Game::GameSettings*, bool, std::string)address [0x7514ee] line: 147
./megaglest:Glest::Game::MenuStateNewGame::mouseClick(int, int, Shared::Platform::MouseButton)address [0x713fe9] line: 95
./megaglest:Glest::Game::MainWindow::eventMouseDown(int, int, Shared::Platform::MouseButton)address [0x64d23e] line: 624
./megaglest:Shared::Platform::Window::handleMouseDown(SDL_Event)address [0x9b06f1] line: 676
./megaglest:Shared::Platform::Window::handleEvent()address [0x9b18b5] line: 161
./megaglest:Glest::Game::glestMain(int, char**)address [0x6741f4] line: 4682
./megaglest:Glest::Game::glestMainWrapper(int, char**)address [0x67909b] line: 4949
/lib/x86_64-linux-gnu/libc.so.6:__libc_start_main()address [0x7fd8dc01676d] line: 0
./megaglest() [0x507289]address [0x507289]

megaglest: /home/tomreyn/SCM/megaglest-trunk/source/glest_game/network/network_manager.cpp:98: Glest::Game::ServerInterface* Glest::Game::NetworkManager::getServerInterface(bool): Assertion `gameNetworkInterface!=__null' failed.

This is not very user friendly, it would be nice to handle this situation by disabling network slots and displaying a message that network slots are unavailable because the gameserver port is in use. If this is hard to program, then maybe there could be a user friendly GUI message explaining why it's exiting there before the window closes.
« Last Edit: 15 November 2012, 21:46:33 by tomreyn »
atibox: Ryzen 1800X (8 cores @3.6GHz), 32 GB RAM, MSI Radeon RX 580 Gaming X 8G, PCI subsystem ID [1462:3417], (Radeon RX 580 chipset, POLARIS10) @3440x1440; latest stable Ubuntu release, (open source) radeon (amdgpu) / mesa video driver
atibox (old): Core2Quad Q9400 (4 cores @2.66GHz), 8 GB RAM, XFX HD-467X-DDF2, PCI subsystem ID [1682:2931], (Radeon HD 4670, RV730 XT) @1680x1050; latest stable Ubuntu release, (open source) radeon / mesa video driver
notebook: HP envy13d020ng
internet access: VDSL2+

· · · How YOU can contribute to MG · Latest development snapshot · How to build yourself · Megapack techtree · Currently hosted MG games · · ·

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,239
    • View Profile
Re: Please handle "Address already in use" socket error more gracefully
« Reply #1 on: 15 November 2012, 15:08:49 »
Fixed in svn (related to the new admin port)

tomreyn

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 2,764
    • View Profile
    • MegaGlest - the free and open source cross platform 3D real-time strategy game
Re: Please handle "Address already in use" socket error more gracefully
« Reply #2 on: 15 November 2012, 21:46:20 »
Thanks, it's is much better now.
atibox: Ryzen 1800X (8 cores @3.6GHz), 32 GB RAM, MSI Radeon RX 580 Gaming X 8G, PCI subsystem ID [1462:3417], (Radeon RX 580 chipset, POLARIS10) @3440x1440; latest stable Ubuntu release, (open source) radeon (amdgpu) / mesa video driver
atibox (old): Core2Quad Q9400 (4 cores @2.66GHz), 8 GB RAM, XFX HD-467X-DDF2, PCI subsystem ID [1682:2931], (Radeon HD 4670, RV730 XT) @1680x1050; latest stable Ubuntu release, (open source) radeon / mesa video driver
notebook: HP envy13d020ng
internet access: VDSL2+

· · · How YOU can contribute to MG · Latest development snapshot · How to build yourself · Megapack techtree · Currently hosted MG games · · ·

treba

  • Guest
hey!
just ran into the same error while trying to setup the engineers again. what do i have to do to fix it?

greeting

tomreyn

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 2,764
    • View Profile
    • MegaGlest - the free and open source cross platform 3D real-time strategy game
One way to use different ports is to pass the ports to use on command line when starting MG, e.g.:
./start_megaglest --use-ports=61377,61377,61375

The other approach would be to use different .INI files for different instaces of the game and to pass the very INI files' location on the command line. And while you can set the game and FTP control + data ports in the INI file I'm not sure whether this would automatically change the game status query port (61375 in the above example), too (and I think there is no separate INI option for it). So the INI approach may or may not work. Running netstat or lsof -i should tell, though.

Thanks for bringing the Engineers back online, they have been missed! :)
atibox: Ryzen 1800X (8 cores @3.6GHz), 32 GB RAM, MSI Radeon RX 580 Gaming X 8G, PCI subsystem ID [1462:3417], (Radeon RX 580 chipset, POLARIS10) @3440x1440; latest stable Ubuntu release, (open source) radeon (amdgpu) / mesa video driver
atibox (old): Core2Quad Q9400 (4 cores @2.66GHz), 8 GB RAM, XFX HD-467X-DDF2, PCI subsystem ID [1682:2931], (Radeon HD 4670, RV730 XT) @1680x1050; latest stable Ubuntu release, (open source) radeon / mesa video driver
notebook: HP envy13d020ng
internet access: VDSL2+

· · · How YOU can contribute to MG · Latest development snapshot · How to build yourself · Megapack techtree · Currently hosted MG games · · ·

treba

  • Guest
alright, with the third port it works again. engi is back to full power =)