Proper closing of socket when exiting app

This commit is contained in:
Daniel Collin 2012-10-30 21:58:56 +01:00
parent 241937cad2
commit af042ad66e
4 changed files with 24 additions and 18 deletions

View File

@ -196,23 +196,14 @@ static SOCKET clientConnect(SOCKET serverSocket, struct sockaddr_in* host)
void RemoteConnection_updateListner()
{
fd_set fds;
struct timeval timeout;
SOCKET clientSocket;
struct sockaddr_in client;
if (RemoteConnection_connected())
return;
FD_ZERO(&fds);
FD_SET(s_serverSocket, &fds);
timeout.tv_sec = 0;
timeout.tv_usec = 0;
// look for new clients
//if (select(0, &fds, NULL, NULL, &timeout) > 0)
{
clientSocket = clientConnect(s_serverSocket, &client);
@ -414,3 +405,14 @@ void RemoteConnection_sendKeyFrames(const char* name, struct sync_track* track)
sendSetKeyCommandIndex((uint32_t)track_id, &track->keys[i]);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void RemoteConnection_close()
{
if (RemoteConnection_connected())
{
closesocket(s_socket);
s_socket = INVALID_SOCKET;
}
}

View File

@ -10,6 +10,7 @@ struct sync_track;
bool RemoteConnection_createListner();
void RemoteConnection_updateListner();
void RemoteConnection_close();
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Talk with the demo stuff

View File

@ -1,5 +1,6 @@
#import "RocketView.h"
#include "../Editor.h"
#include "../rlog.h"
#include <Emgui.h>
#include <GFXBackend.h>
@ -157,14 +158,5 @@
return YES;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-(void) dealloc
{
Editor_destroy();
EMGFXBackend_destroy();
[super dealloc];
}
@end

View File

@ -1,6 +1,8 @@
#import "delegate.h"
#include "../Editor.h"
#include "../RemoteConnection.h"
#include "rlog.h"
@implementation MinimalAppAppDelegate
@ -20,4 +22,13 @@
Editor_menuEvent((int)((NSButton*)sender).tag);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- (void)applicationWillTerminate:(NSNotification *)aNotification
{
rlog(R_INFO, "Dealloc\n");
Editor_destroy();
RemoteConnection_close();
}
@end